3 require_once('library/HTML5/Parser.php');
6 function parse_url_content(&$a) {
8 $url = trim($_GET['url']);
12 $template = "<a href=\"%s\" >%s</a>%s";
22 echo sprintf($template,$url,$url,'');
26 $dom = @HTML5_Parser::parse($s);
31 $items = $dom->getElementsByTagName('title');
34 foreach($items as $item) {
35 $title = trim($item->textContent);
41 $divs = $dom->getElementsByTagName('div');
43 foreach($divs as $div) {
44 $class = $div->getAttribute('class');
45 if($class && stristr($class,'article')) {
46 $items = $div->getElementsByTagName('p');
48 foreach($items as $item) {
49 $text = $item->textContent;
50 $text = strip_tags($text);
51 if(strlen($text) < 100)
53 $text = substr($text,0,250) . '...' ;
62 $items = $dom->getElementsByTagName('p');
64 foreach($items as $item) {
65 $text = $item->textContent;
66 $text = strip_tags($text);
67 if(strlen($text) < 100)
69 $text = substr($text,0,250) . '...' ;
76 $text = '<br />' . $text;
79 echo sprintf($template,$url,$title,$text);