Php 警告:文件\u获取\u内容()无法打开流
目前,我正在尝试获取https网站的结果,在使用simple_html_dom.php时,我遇到了这个错误,有人能告诉我如何修复这个问题,或者是什么潜在的原因吗Php 警告:文件\u获取\u内容()无法打开流,php,Php,目前,我正在尝试获取https网站的结果,在使用simple_html_dom.php时,我遇到了这个错误,有人能告诉我如何修复这个问题,或者是什么潜在的原因吗 Warning: file_get_contents(https://crimson.gg/jackpot-history): failed to open stream: HTTP request failed! HTTP/1.1 503 Service Temporarily Unavailable in /tickets/simp
Warning: file_get_contents(https://crimson.gg/jackpot-history): failed to open stream: HTTP request failed! HTTP/1.1 503 Service Temporarily Unavailable in /tickets/simple_html_dom.php on line 75
simple_html_dom.php的第75行是这样的
function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
{
// We DO force the tags to be terminated.
$dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
// For sourceforge users: uncomment the next line and comment the retreive_url_contents line 2 lines down if it is not already done.
$contents = file_get_contents($url, $use_include_path, $context, $offset);
// Paperg - use our own mechanism for getting the contents as we want to control the timeout.
//$contents = retrieve_url_contents($url);
if (empty($contents) || strlen($contents) > MAX_FILE_SIZE)
{
return false;
}
// The second parameter can force the selectors to all be lowercase.
$dom->load($contents, $lowercase, $stripRN);
return $dom;
}
我现在使用的代码是
$html = file_get_html('https://crimson.gg/jackpot-history');
foreach($html->find('#contentcolumn > a') as $element)
{
print '<br><br>';
echo $url = 'https://crimson.gg/'.$element->href;
$html2 = file_get_html($url);
$title = $html2->find('#contentcolumn > a',0);
print $title = $title->plaintext;
}
可能文件不存在,或者您没有读取该文件的权限。检查文件是否存在permission@Md.SahadatHossain当我将其更改为
curl
时,它可以工作,但它会从预加载cloudflare页面中提取内容。我需要考虑如何延迟它,这样当cloudflare页面过期时,它就会删除或使上面的代码正常工作。
foreach($html->find('#contentcolumn > a') as $element)