Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for using MultiCurl with multiple proxies #572

Closed
nerokc2 opened this issue Jan 31, 2019 · 6 comments

Comments

Projects
None yet
4 participants
@nerokc2
Copy link

commented Jan 31, 2019

Can you add proxylist for multicurl? Because 1 proxy for many concurency is bad

@zachborboa

This comment has been minimized.

Copy link
Collaborator

commented Feb 1, 2019

@nerokc2

This comment has been minimized.

Copy link
Author

commented Feb 1, 2019

But in example uses 1 proxy for many concurency

@zachborboa zachborboa added the Accepted label Feb 1, 2019

@zachborboa zachborboa self-assigned this Feb 1, 2019

@zachborboa zachborboa changed the title Multicurl proxy Add support for using MultiCurl with multiple proxies Feb 1, 2019

@k00ni

This comment has been minimized.

Copy link
Contributor

commented Feb 13, 2019

Why not create multiple MultiCurl classes and use different proxies?

$multi_curlA = new MultiCurl();
$multi_curlA->setProxy('127.0.0.1:8080');
// setup instance, run addGet, ...

$multi_curlB = new MultiCurl();
$multi_curlB->setProxy('127.0.0.1:9999');
// setup instance, run addGet, ...

// start
$multi_curlA->start();
$multi_curlB->start();

Untested

@nerokc2

This comment has been minimized.

Copy link
Author

commented Feb 14, 2019

i say about proxy list for many concurency

@masroore

This comment has been minimized.

Copy link

commented Feb 23, 2019

Initiate your own Curl instances with individual proxies and add it to the MultiCurl instance.

This should give you an idea:

$a = new Curl(); $a->setProxy('127.0.0.1:8080');
$b = new Curl(); $b->setProxy('127.0.0.1:8888');
$mc = new MultiCurl();
$mc->addCurl($a);
$mc->addCurl($b);

untested

Alternately you may use MultiCurl::beforeSend() to customize each Curl object..

@zachborboa

This comment has been minimized.

Copy link
Collaborator

commented May 12, 2019

Hi, Using multiple proxies is now possible:

$multi_curl = new MultiCurl();
$multi_curl->setProxies(array(
    'someproxy.com:9999',
    'someproxy.com:80',
    'someproxy.com:443',
    'someproxy.com:1080',
    'someproxy.com:3128',
    'someproxy.com:8080',
));
$multi_curl->addGet('https://httpbin.org/ip');
$multi_curl->addGet('https://httpbin.org/ip');
$multi_curl->addGet('https://httpbin.org/ip');
$multi_curl->complete(function ($instance) {
    echo
        'curl id ' . $instance->id . ' used proxy ' .
        $instance->getOpt(CURLOPT_PROXY) . ' and ' .
        'ip is ' . $instance->response->origin . "\n";
});
$multi_curl->start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.