There is an array of target url

$urlArray = array('aaa','bbb','xxx','yyy','zzz');

The size of the array is not known in advance. There is also an array of proxy servers

$proxyArray = array('iii','jjj','kkk');

The size of this array is also not known.

The task is to get the maximum probability of getting 200 http_code for all url from $ urlArray array using parallel curl and proxy requests.

Such a solution comes to mind: loop the requests with further exclusion from the url array for which the answer 200 was, as the array with the url decreases, assign the same url to several proxy servers until the url array remains empty. The problem is that with this solution the target server is very heavily loaded: several requests will be sent to one url. Perhaps prompt more correct decision?

    1 answer 1

    Something tells me that the load on the target server will be so miserable that he will not even feel it.

    But, if you still want, then the best option would be to use a nested loop.

     $urlArray = array('aaa','bbb','xxx','yyy','zzz'); $proxyArray = array('iii','jjj','kkk'); $out = array(); foreach($urlArray as $url){ foreach($proxyArray as $proxy){ .... if($retCode == 200) { $out[] = $url; break; } } } foreach ($out as $url){ if(!in_array($url, $urlArray)) echo "Bad URL: ".$url.PHP_EOL; } 
    • in theory, a variant is possible that several thousand proxies will be “breaking” on one url - user193361