我想从纯
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)