我得到一个空白屏幕后,我运行下面的代码str_get_html不工作,返回空白
<?php include('simple_html_dom.php');
$html = getSslPage('https://www.reddit.com/r/nottheonion/comments/3aev89/kim_jongun_claims_to_have_cured_aids_ebola_and/');
function getSslPage($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$html = str_get_html($html);
echo $html;
调试它是与其他网址有时工作中最难的部分。我想知道为什么页面具有相同的DOM结构。任何人都知道为什么会发生?
那么str_get_html()是什么?它不是一个核心的PHP函数 –
@MarkBaker从字符串创建一个DOM对象http://simplehtmldom.sourceforge.net/manual.htm –
那么simple_html_dom函数str_get_html()返回一个__object__,不一定是你可以回显,除非它有一个魔术__toString()方法......当你回应它时你期望看到什么? –