浅析php插件 Simple HTML DOM 用DOM方式处理HTML

simple_html_dom插件
用dom处理html文件的利器
使用:
加载simple_html_dom.php文件

require_once 'simple_html_dom.php'

new simple_html_dom对象

$dom = new simple_html_dom()

加载html

$dom->load($html);

find()方法

$dom->find('div.lookLeftname', 0)->plaintext

class=‘lookLeftname'的div中的纯文本

$dom->find('div.lookLeftname', 0)->innertext

class='lookLeftname'的div中的内部文本
plaintext 与innertext最常用的