最近几个月,我的cURL实现一直顺利运行,没有出现任何问题;然而,上周我突然在一个特定的网站(www.viewmag.com)上遇到了问题。我可以在浏览器中访问该网站,并且它能够很好地解析,但是cURL返回以下内容:
* About to connect() to www.viewmag.com port 80 (#0)
* Trying 205.178.145.65... * Timeout
* connect() timed out!
* Closing connection #0
为了排除问题,我尝试使用两个不同的设备对该网站进行ping测试,但每次ping测试均超时。
设备1(Linux):
ping www.viewmag.com
PING www.viewmag.com (205.178.145.65) 56(84) bytes of data.
盒子 2 (Windows):
ping www.viewmag.com
Pinging www.viewmag.com [205.178.145.65] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
我的 cURL 如下:
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'http://www.viewmag.com');
curl_setopt ($ch, CURLOPT_USERAGENT, 'cURL crawler');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt ($ch, CURLOPT_AUTOREFERER, true);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 2);
$html = curl_exec($ch);
有没有人能想到为什么cURL失败,我可以在浏览器中访问该网站,但无法ping或使用cURL?提前致谢。
http://www.viewmag.com
吗? - hek2mgl