使用PHP curl模拟Firefox自动代理配置

时间:2016-09-14 21:47:39

标签: php proxy

我认为Firefox自动代理配置是TSL 1.2:

    $headers = array(
            'host:ip-adress.eu',
            'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0',
            'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Language: en-US,en;q=0.5',
            'Accept-Encoding: gzip, deflate, br',               
            'Proxy-Authorization: Basic b2xkLmV1cm9tYWtlckB5YWhvby5jb206WEpzV0Uwc0ZqT1pOK2MydDZWZWc4WWFreklaUVVDSUcxbDVrWE1yK0xKVT0=',
            'Connection: keep-alive'
    );

$proxy = "GQ2S4MZSFYZTMLRRHAYSGMJUG4ZTQMJRGIYDA.cd-n.net:143";

$url = 'ip-adress.eu';
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_SSLVERSION, 6);
    curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, true); // OK
    curl_setopt($curl, CURLOPT_PROXY, $proxy); // OK

    curl_setopt($curl, CURLOPT_URL, trim($url)); // OK
    curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0'); // OK

    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($curl, CURLOPT_TIMEOUT,  30);
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($curl, CURLOPT_VERBOSE, false);
    $httpresult = curl_exec($curl);
    $httpstatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);

print curl_errno ($curl); 
curl_close($curl);

此代码返回CURL错误 - 卷曲:(56)Recv失败:由对等方重置连接

0 个答案:

没有答案