2015-06-21 67 views
0

我得到一个空白屏幕后,我运行下面的代码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结构。任何人都知道为什么会发生?

+0

那么str_get_html()是什么?它不是一个核心的PHP函数 –

+0

@MarkBaker从字符串创建一个DOM对象http://simplehtmldom.sourceforge.net/manual.htm –

+0

那么simple_html_dom函数str_get_html()返回一个__object__,不一定是你可以回显,除非它有一个魔术__toString()方法......当你回应它时你期望看到什么? –

回答

2

这是因为html字符串太大而且simple_html_dom具有可解析的最大限制。以下是你可以做些什么来增加限制。

打开simple_html_dom.php和改变这一行

define('MAX_FILE_SIZE', 6000000); 

到更多的东西..尝试

define('MAX_FILE_SIZE', 60000000); // add a zero at the end 

这应该解决的问题。让我知道,如果情况并非如此。

+0

嘿非常感谢!它解决了我的问题! –

+0

很高兴!如果有帮助,请'接受'答案。 – Vishwa