运行下面的代码后出现黑屏
<?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;
调试它最困难的部分是它有时会与其他 url 一起工作。我想知道为什么页面具有相同的 DOM 结构。任何人都知道为什么会这样?
最佳答案
是因为html字符串太大,simple_html_dom有最大解析限制。以下是您可以提高限制的方法。
打开 simple_html_dom.php
并更改这一行
define('MAX_FILE_SIZE', 6000000);
更多..尝试
define('MAX_FILE_SIZE', 60000000); // add a zero at the end
这应该可以解决问题。如果不是这样,请告诉我。
关于php - str_get_html 不起作用并返回空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30966569/