我想从纯
PHP的外部网站获得DIV.
外部网站:http://www.isitdownrightnow.com/youtube.com.html
我希望来自isitdownrightNow(statusup div)的Div文本:< div class =“statusup”>该网站可能只适合您…< / div>
我已经尝试过使用DOMDocument和str_get_html的file_get_contents,但我无法让它工作.
例如这个
$page = file_get_contents('http://css-tricks.com/forums/topic/jquery-selector-div-variable/'); $doc = new DOMDocument(); $doc->loadHTML($page); $divs = $doc->getElementsByTagName('div'); foreach($divs as $div) { // Loop through the DIVs looking for one withan id of "content" // Then echo out its contents (pardon the pun) if ($div->getAttribute('class') === 'bbp-template-notice') { echo $div->nodeValue; } }
Failed to load resource: the server responded with a status of 500
(Internal Server Error)
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。