我正在使用Simple HTML DOM解析器来获取一些数据。一切都很好但我在WordPress网站上启用阅读更多插件时遇到了问题。
隐藏内容(文章的其余内容)位于此div
内。
样本:
<div class="mycontent">
Here is some content
<div class="brm" style="display: none;">
Here is another content but it's not vissible because the style of this div is set to display:none
</div>
<p><a href="#" class="brm-more-link">read more..</a></p>
</div>
到目前为止,我正在使用:
$url = "www.myurl.com";
$html = new simple_html_dom();
$html->load_file($url);
$maindiv = $html->find('div.mycontent',0)->outertext;
它会显示除div <div class="brm" style="display: none;">
如何获取隐藏内容的任何想法?
答案 0 :(得分:0)
它确实得到了那个div:
include 'simple_html_dom.php';
$str = <<<EOF
<script type="text/javascript">
<div class="mycontent">
Here is some content
<div class="brm" style="display: none;">
Here is another content but it's not vissible because the style of this div is set to display:none
</div>
<p><a href="#" class="brm-more-link">read more..</a></p>
</div>
EOF;
$html = str_get_html($str);
echo $html->find('div.mycontent',0)->outertext;
// <div class="mycontent"> Here is some content <div class="brm" style="display: none;"> Here is another content but it's not vissible because the style of this div is set to display:none </div> <p><a href="#" class="brm-more-link">read more..</a></p> </div>