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>';
原文地址:https://www.cnblogs.com/souroot/p/4453192.html