3 require_once('library/HTML5/Parser.php');
5 function parse_url_content(&$a) {
7 $url = trim($_GET['url']);
11 $template = "<a href=\"%s\" >%s</a>%s";
21 echo sprintf($template,$url,$url,'');
25 $dom = HTML5_Parser::parse($s);
30 $items = $dom->getElementsByTagName('title');
33 foreach($items as $item) {
34 $title = trim($item->textContent);
40 $divs = $dom->getElementsByTagName('div');
42 foreach($divs as $div) {
43 $class = $div->getAttribute('class');
44 if($class && stristr($class,'article')) {
45 $items = $div->getElementsByTagName('p');
47 foreach($items as $item) {
48 $text = $item->textContent;
49 $text = strip_tags($text);
50 if(strlen($text) < 100)
52 $text = substr($text,0,250) . '...' ;
61 $items = $dom->getElementsByTagName('p');
63 foreach($items as $item) {
64 $text = $item->textContent;
65 $text = strip_tags($text);
66 if(strlen($text) < 100)
68 $text = substr($text,0,250) . '...' ;
75 $text = '<br />' . $text;
78 echo sprintf($template,$url,$title,$text);