Max*_*ler 4 parsing dom simple-html-dom
如何使用PHP简单的HTML DOM解析器获取Div类中的内容.
在这里,我想从div类中获取内容,如:
<div class="post" imposition="usermanual">Some Content </div>
Run Code Online (Sandbox Code Playgroud)
那么,使用这个div类获取内容的方法是什么post?我试过这段代码但是不行:
$es = $html->find('.post');
$es = $html->find('div.post'); // also try this
$es = $html->find('div[class="post"]'); // also try this
Run Code Online (Sandbox Code Playgroud)
任何的想法?
在如何访问HTML元素的属性的Magic Attributes选项卡下,您将找到如何访问对象的属性.还有一处房产.innertextplaintext
$es = $html->find('div[class="post"]', 0);
echo $es->innertext; // Some Content
Run Code Online (Sandbox Code Playgroud)