如何使用PHP Simple HTML DOM Parser获取Div类中的内容。
在这里,我想从div类获取内容,如下所示:
<div class="post" imposition="usermanual">Some Content </div>那么,使用这个div类post获取内容的方法是什么呢?我试过这段代码,但不起作用:
$es = $html->find('.post');
$es = $html->find('div.post'); // also try this
$es = $html->find('div[class="post"]'); // also try this有什么想法吗?
发布于 2012-12-07 01:46:13
在How to access the HTML element's attributes的Magic Attributes选项卡下,您将了解如何访问对象的innertext属性。还有一个plaintext属性。
$es = $html->find('div[class="post"]', 0);
echo $es->innertext; // Some Content https://stackoverflow.com/questions/13749261
复制相似问题