【发布时间】:2020-04-02 04:01:17
【问题描述】:
我通过simple dom html (file_get_html('http://example.com')) 得到底部的html代码
<div id="ship" class="fe" data-feature-name="box" data-cel-widget="sox">
<div class="a-medium b-di">
<div id="mer-info" class="a-section a-spacing-mini">
Hello World
<span class="">
</span>
</div>
</div>
</div>
如何获取“Hello World”内容文本?
我尝试了很多东西,例如底部文本,但这给了我 'NULL'
$html->find('div[id="mer-info"]',0);
$html->find("div#mer-info");
$html->find("div#mer-info")->plaintext;
$html->find('div[id="mer-info"]')->innertext;
and ...
但我还是 NULL!
【问题讨论】:
-
请提供您的代码示例。不清楚您如何使用
file_get_html(),我测试了您的三种方法,其中两种确实有效,因此问题可能与您如何检索 html 有关。 -
@Nima 我更新了。我得到带有
file_get_html的HTML 代码 如何使用simple_html_dom.php访问所有div内容 -
这个问题在这里可能已经有了答案...stackoverflow.com/questions/33053528/…
标签: php simple-html-dom