卷曲得到其他网站而不是请求

时间:2016-12-07 19:14:37

标签: php curl

我尝试通过php CURL加载页面http://ars-sps.ru/all-contact,但结果CURL返回网页http://legaljapan.jp

怎么可能?

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);

1 个答案:

答案 0 :(得分:1)

不要使用" CURLOPT_USERAGENT"帕拉姆然后。