我得到一個空白屏幕後,我運行下面的代碼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()方法......當你迴應它時你期望看到什麼? –