php解析html

用simple_html_dom

下载地址:https://github.com/samacs/simple_html_dom

解析超链接描述

1 $html = file_get_html('http://www.baidu.com/');
2 
3 // find all link
4 foreach($html->find('a') as $e) 
5 echo $e->innertext . '<br>';

如果是解析超链接url:

1 $html = file_get_html('http://www.baidu.com/');
2 
3 // find all link
4 foreach($html->find('a') as $e) 
5 echo $e->href . '<br>';

 

posted @ 2015-04-24 13:14  souroot  阅读(626)  评论(0编辑  收藏  举报