"failed to open stream: Connection timed out" 即使远程站点已启动并且 运行

"failed to open stream: Connection timed out" even though the remote site is up and running

我正在测试一个 PHP 脚本,以使用简单 HTML DOM 解析器库抓取远程站点。代码过去工作正常;然而,今天突然停止了。

<?php

require_once 'backend/connector.php';
require_once 'table_access/simplehtmldom_1_5/simple_html_dom.php';
ini_set("display_errors", 1);
error_reporting(E_ALL);
echo file_get_html("http://www.google.com");

?>

它给出的错误是:

Warning: file_get_contents(http://www.google.com): failed to open stream: Connection timed out in /home/peppyoil/public_html/sandboxassets/engines/table_access/simplehtmldom_1_5/simple_html_dom.php on line 75

尽管通过浏览器访问远程站点非常可用,但我不明白为什么它会反复超时。我会理解它说连接被拒绝或类似的东西但是什么可以解释超时?

我尝试使用 cURL:

<?php

$ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, 'http://www.google.com');
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_PROXY, $proxy); // $proxy is ip of proxy server
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
 curl_setopt($ch, CURLOPT_TIMEOUT, 10);
 $httpCode = curl_getinfo($ch , CURLINFO_HTTP_CODE); // this results 0 every time
 $response = curl_exec($ch);
 if ($response === false) $response = curl_error($ch);
 echo stripslashes($response);
 curl_close($ch);

 ?>

这次没有成功,或者抛出以下错误:

Connectiontimed out after 10001 milliseconds

上面给出的测试脚本位于http://www.peppyburro.com/sandboxassets/engines/test1.php

更新 2:刚刚检查了我的 80 端口,发现了这个:

Outbound Port 80, 443, 587 and 465 for your account are BLOCKED Reason for the port block: During our regular scans, we have found malicious files in your account which may be infected with malware.

这可能与超时有关吗?

Outbound Port 80, 443, 587 and 465 for your account are BLOCKED Reason for the port block: During our regular scans, we have found malicious files in your account which may be infected with malware.

上面已经说过,您的托管服务提供商发现您网站的内容是恶意的。

这是因为您要实现的目标类似于代理服务器,属于 URL 重写站点部分。因此您不能托管该脚本,因为它可用于直接访问在您所在地区被阻止但在您的托管服务提供商地区不被阻止的内容。

希望对您有所帮助。