Php 请改为获取其他网站

Php 请改为获取其他网站,php,curl,Php,Curl,我尝试通过php CURL加载页面,但结果CURL返回网页 怎么可能呢 PHP代码: $headers = array( 'Expect:', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9', 'Accept-Language: ru,en-us;q=0.7,en;q=0.7', 'Accept-Charset: utf-8,windows-12

我尝试通过php CURL加载页面,但结果CURL返回网页

怎么可能呢

PHP代码:

    $headers = array(
        'Expect:',
        'Accept: text/html,application/xhtml+xml,application/xml;q=0.9',
        'Accept-Language: ru,en-us;q=0.7,en;q=0.7',
        'Accept-Charset: utf-8,windows-1251;q=0.7,*;q=0.5',
    );

    $ch = curl_init();
    curl_setopt( $ch, CURLOPT_URL, 'http://ars-sps.ru/all-contact' );
    curl_setopt($ch, CURLOPT_PORT, 80);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); 
    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
    curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090716 Ubuntu/9.04 (jaunty) Shiretoko/3.5.1');
    curl_setopt($ch, CURLOPT_VERBOSE, 2); 
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
    curl_setopt($ch, CURLOPT_MAXREDIRS, 7); 
    curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_COOKIEFILE, 'curl_cookie.txt');
    curl_setopt($ch, CURLOPT_COOKIEJAR, 'curl_cookie.txt');

    echo $page = curl_exec($ch);

然后不要使用“CURLOPT_USERAGENT”参数。

所以,如果您在浏览器中打开,它会重定向您。谢谢,帮助。但我不明白为什么?在这里我把“CURLOPT_USERAGENT”放在下面,并在你的代码curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0(X11;U;Linux i686;en-US;rv:1.9.1)Gecko/20090622 Ubuntu/9.04(jaunty)Shiretoko/3.5');我认为服务器正在重定向您,因为您的用户代理有问题。在您的用户代理参数中,将“Linux x86_64”更改为匹配的。