今天就跟大家聊聊有關(guān)怎么在php中使用simple_html_dom解析HTML,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。
用法示例:
find('a') as $e) echo $e->href . '
'; // find all image foreach($html->find('img') as $e) echo $e->src . '
'; // find all image with full tag foreach($html->find('img') as $e) echo $e->outertext . '
'; // find all div tags with id=gbar foreach($html->find('div#gbar') as $e) echo $e->innertext . '
'; // find all span tags with class=gb1 foreach($html->find('span.gb1') as $e) echo $e->outertext . '
'; // find all td tags with attribite align=center foreach($html->find('td[align=center]') as $e) echo $e->innertext . '
'; // extract text from table echo $html->find('td[align="center"]', 1)->plaintext.'
'; // extract text from HTML echo $html->plaintext; ?>
看完上述內(nèi)容,你們對怎么在php中使用simple_html_dom解析HTML有進(jìn)一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。