Comments (4)
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.
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.
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:
php-curl-class/src/Curl/MultiCurl.php
Lines 1277 to 1280 in 3ff53bf
from php-curl-class.
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)
- Deprecated: Creation of dynamic property Curl\Curl::$rfc6265 is deprecated HOT 2
- CurlStringFile: Object of class CURLStringFile could not be converted to string HOT 1
- Having issues with post json or array HOT 1
- Update ci to work with PHPUnit 10 HOT 1
- Fix recently failing CI HOT 1
- Return types HOT 3
- Unsupported protocol (CURLE_UNSUPPORTED_PROTOCOL): Protocol "ftp" not supported or disabled in libcurl HOT 3
- 302 Moved Temporarily HOT 1
- Curl->diagnose(), uncaught type error if Content-Type is null, PHP 8.1.13 HOT 3
- How to get the list of URLs that have not been executed yet when I use MultiCurl::stop() HOT 3
- Retry manually HOT 3
- issue with response content being double decoded HOT 5
- Detected an illegal character in input string in /var/www/site/vendor/symfony/polyfill-mbstring/Mbstring.php:536 HOT 2
- Error code: 18 error message: Transferred a partial file (CURLE_PARTIAL_FILE): HTTP/2 stream 1 was not closed cleanly HOT 1
- Curl::afterSend with MultiCurl::addCurl HOT 1
- Fix CI
- Fix CI
- multicurl file_get_contents() HOT 1
- setRetry() HOT 1
- MultiCurl
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-curl-class.