douba9425 2018-11-01 17:00 采纳率: 100%
浏览 57

旋转代理,直到找到CURL的工作代理

I'm trying to connect to a website using CURL with proxy on localhost using Xampp.

Here is the CURL code:

$url= 'https://stubhub.com/';
$curl = curl_init();
curl_setopt( $curl, CURLOPT_URL, $url );
curl_setopt($curl, CURLOPT_REFERER, $url);
curl_setopt( $curl, CURLOPT_AUTOREFERER, TRUE );
curl_setopt( $curl, CURLOPT_HEADER, FALSE );
curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, 0 );
curl_setopt( $curl, CURLOPT_TIMEOUT, 0 );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE );
curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, TRUE );
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);

//SSL
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);

//User-Agent
curl_setopt( $curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' );

//Proxy
$proxies = '';
curl_setopt($curl, CURLOPT_PROXY, $proxy);
curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, TRUE);


//Errors
curl_setopt($curl, CURLOPT_VERBOSE, TRUE);

$data = curl_exec( $curl );
$info = curl_getinfo( $curl );
$error = curl_error( $curl );
curl_close( $curl );

I get 1 of 4 errors each time: 1-

Array
(
    [data] => 
    [info] => Array
        (
            [url] => https://www.stubhub.com/
            [content_type] => 
            [http_code] => 0
            [header_size] => 0
            [request_size] => 225
            [filetime] => -1
            [ssl_verify_result] => 0
            [redirect_count] => 0
            [total_time] => 56.437
            [namelookup_time] => 0
            [connect_time] => 0.296
            [pretransfer_time] => 0
            [size_upload] => 0
            [size_download] => 0
            [speed_download] => 0
            [speed_upload] => 0
            [download_content_length] => -1
            [upload_content_length] => -1
            [starttransfer_time] => 0
            [redirect_time] => 0
            [redirect_url] => 
            [primary_ip] => 103.94.120.66
            [certinfo] => Array
                (
                )

            [primary_port] => 52131
            [local_ip] => 192.168.1.25
            [local_port] => 59947
        )

    [error] => Recv failure: Connection was reset
)

2-

Array
(
    [data] => 
    [info] => Array
        (
            [url] => https://www.stubhub.com/
            [content_type] => 
            [http_code] => 0
            [header_size] => 0
            [request_size] => 0
            [filetime] => -1
            [ssl_verify_result] => 0
            [redirect_count] => 0
            [total_time] => 20.203
            [namelookup_time] => 0
            [connect_time] => 0
            [pretransfer_time] => 0
            [size_upload] => 0
            [size_download] => 0
            [speed_download] => 0
            [speed_upload] => 0
            [download_content_length] => -1
            [upload_content_length] => -1
            [starttransfer_time] => 0
            [redirect_time] => 0
            [redirect_url] => 
            [primary_ip] => 
            [certinfo] => Array
                (
                )

            [primary_port] => 0
            [local_ip] => 
            [local_port] => 0
        )

    [error] => Failed to connect to 103.94.120.66 port 52131: Timed out
)

3-

[error] => Failed to connect to 74.194.6.225 port 44181: Connection refused

4-

[error] => Proxy CONNECT aborted

So how to rotate the proxies with a working proxy that would connect to the website correctly?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法
    • ¥15 可否在不同线程中调用封装数据库操作的类
    • ¥15 微带串馈天线阵列每个阵元宽度计算
    • ¥15 keil的map文件中Image component sizes各项意思
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏