Coder Social home page Coder Social logo

Comments (4)

zachborboa avatar zachborboa commented on June 14, 2024 1

The issue with high memory use should be resolved by using a pattern like this:
https://github.com/php-curl-class/php-curl-class/blob/master/examples/multi_curl_add_curl_from_url_list.php

To use a unique random proxy, something like this could work:
https://github.com/php-curl-class/php-curl-class/blob/master/examples/multi_curl_get_with_new_random_unique_proxy.php

from php-curl-class.

enseitankado avatar enseitankado commented on June 14, 2024 1

The idea of destroying the once used proxy inside the beforeSend procedure is nice.
Unfortunately I did this by modifying the library itself, which would create additional work in updating the library. Now I'm familiar with the beforeSend function. Thanks for the illustrative sample program.

Funny thing is, I realized that I persisted in my question about memory consumption. When I looked a little more carefully, I decided that the example you gave worked correctly.

I see you are a few steps ahead of me. Thank you for your patience.

from php-curl-class.

zachborboa avatar zachborboa commented on June 14, 2024

Hi. You can add additional requests after starting to reduce memory consumption. Take a look at this example:
https://github.com/php-curl-class/php-curl-class/blob/master/examples/multi_curl_add_curl_from_url_list.php

When using proxies, a desired proxy can be set on the individual request and a random proxy won't override the existing proxy:

if (is_array($this->proxies) && $curl->getOpt(CURLOPT_PROXY) === null) {
$random_proxy = ArrayUtil::arrayRandom($this->proxies);
$curl->setProxy($random_proxy);
}

from php-curl-class.

enseitankado avatar enseitankado commented on June 14, 2024

Hi,

As I mentioned at the beginning; Let's say I define 100 proxies and 100 get. The library does this randomly when choosing the proxy to use for get requests. This has two downsides. First, the same proxy can be selected again, and the other can include a proxy that has never been used when 100 requests are complete. An optional key is required to use the library random proxy.

Multithread requires a certain number of get requests to start at the same time. However, the code in the example moves on to the next request after one request is complete. So the example is sequential, not multithreaded.

 if (is_array($this->proxies) && $curl->getOpt(CURLOPT_PROXY) === null) { 
     $random_proxy = ArrayUtil::arrayRandom($this->proxies); 
     $curl->setProxy($random_proxy); 
 } 

from php-curl-class.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.