|
用dom處理html文件的利器
使用:
加載simple_html_dom.php文件
復(fù)制代碼 代碼如下:
require_once 'simple_html_dom.php'
new simple_html_dom對(duì)象
復(fù)制代碼 代碼如下:
$dom = new simple_html_dom()
加載html
復(fù)制代碼 代碼如下:
$dom->load($html);
find()方法
復(fù)制代碼 代碼如下:
$dom->find('div.lookLeftname', 0)->plaintext
class=‘lookLeftname'的div中的純文本
復(fù)制代碼 代碼如下:
$dom->find('div.lookLeftname', 0)->innertext
class='lookLeftname'的div中的內(nèi)部文本
plaintext 與innertext最常用的
php技術(shù):淺析php插件 Simple HTML DOM 用DOM方式處理HTML,轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。