diff options
Diffstat (limited to 'mod/parse_url.php')
-rw-r--r-- | mod/parse_url.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/mod/parse_url.php b/mod/parse_url.php new file mode 100644 index 000000000..33381a0d2 --- /dev/null +++ b/mod/parse_url.php @@ -0,0 +1,32 @@ +<?php + +require_once('library/HTML5/Parser.php'); + +function parse_url_content(&$a) { + $url = trim($_GET['url']); + + $template = "<a href=\"%s\" >%s</a>"; + + if($url) + $s = fetch_url($url); + + if(! $s) { + echo sprintf($template,$url,$url); + killme(); + } + + $dom = HTML5_Parser::parse($s); + + if(! $dom) + return $ret; + + $items = $dom->getElementsByTagName('title'); + + foreach($items as $item) { + $title = $item->textContent; + break; + } + + echo sprintf($template,$url,$title); + killme(); +}
\ No newline at end of file |