windk

php 解析dom,可用作抓取工具

// Create DOM from URL or file
$html = file_get_html('http://www.google.com/');

// Find all images
foreach($html->find('img') as $element)
echo $element->src . '<br>';

// Find all links
foreach($html->find('a') as $element)
echo $element->href . '<br>'

  http://simplehtmldom.sourceforge.net/

posted on 2011-09-06 11:22  windk  阅读(273)  评论(0)    收藏  举报

导航