今天就跟大家聊聊有關(guān)怎么在php中使用simple_html_dom解析HTML,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。
成都創(chuàng)新互聯(lián)公司-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比硯山網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫(kù),直接使用。一站式硯山網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋硯山地區(qū)。費(fèi)用合理售后完善,十載實(shí)體公司更值得信賴。用法示例:
<?php // example of how to use basic selector to retrieve HTML contents include('../simple_html_dom.php'); // get DOM from URL or file $html = file_get_html('http://www.google.com/'); // find all link foreach($html->find('a') as $e) echo $e->href . '<br>'; // find all image foreach($html->find('img') as $e) echo $e->src . '<br>'; // find all image with full tag foreach($html->find('img') as $e) echo $e->outertext . '<br>'; // find all div tags with id=gbar foreach($html->find('div#gbar') as $e) echo $e->innertext . '<br>'; // find all span tags with class=gb1 foreach($html->find('span.gb1') as $e) echo $e->outertext . '<br>'; // find all td tags with attribite align=center foreach($html->find('td[align=center]') as $e) echo $e->innertext . '<br>'; // extract text from table echo $html->find('td[align="center"]', 1)->plaintext.'<br><hr>'; // extract text from HTML echo $html->plaintext; ?>
看完上述內(nèi)容,你們對(duì)怎么在php中使用simple_html_dom解析HTML有進(jìn)一步的了解嗎?如果還想了解更多知識(shí)或者相關(guān)內(nèi)容,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。
當(dāng)前題目:怎么在php中使用simple_html_dom解析HTML-創(chuàng)新互聯(lián)
URL網(wǎng)址:http://muchs.cn/article42/cocjhc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊(cè)、外貿(mào)建站、用戶體驗(yàn)、網(wǎng)站制作、App開發(fā)、做網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容