[如何通过简单的html dom-php获取div的内容文本

问题描述 投票:0回答:2

我通过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!

php simple-html-dom
2个回答
0
投票

0
投票
© www.soinside.com 2019 - 2024. All rights reserved.