卷曲停止在我的服务器上工作

时间:2016-01-06 10:08:14

标签: php curl

卷曲停止在我的服务器上工作,但它在另一台服务器上完美运行

这是我的剧本:

 <?php
    $proxy_ip = '165.139.149.169'; 
    $proxy_port = '3128';
    $url = 'https://www.google.com/search?q=skinny+fiber+ingredients&btnG=Search&client=ubuntu&channel=fs&num=100&ie=utf-8&oe=utf-8&gfe_rd=cr&ei=sw9CVbCuPKaA8QfX0ICYBA&gws_rd=cr';  
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    
    curl_setopt($ch, CURLOPT_REFERER, 'https://www.google.com');
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:28.0) Gecko/20100101 Firefox/28.0');
    curl_setopt($ch, CURLOPT_MAXREDIRS, 5); // Good leeway for redirections.    
    curl_setopt($ch, CURLOPT_PROXYPORT, $proxy_port);
    curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');    
    curl_setopt($ch, CURLOPT_PROXY, $proxy_ip);  
    //curl_setopt($ch, CURLOPT_PROXYUSERPWD, $loginpassw);
    $data = curl_exec($ch);
    curl_close($ch);
    echo "abc";
    echo $data;
?>

http://serpbull.com/dev/curl.php(脚本不在这里工作) http://imarkdev.com/serp/curl.php(脚本在这里工作)

编辑: 不工作脚本需要很长时间才能响应(卷曲超时)并打印空响应。

1 个答案:

答案 0 :(得分:0)

使用curl_error()函数获取有关失败的更多信息。

$data = curl_exec($ch);
if ($data === false)
{
    echo 'Curl error: ' . curl_error($ch);
} else {
    echo 'Response: ' . $data;
}