Hello There is a curle

function curl($url,$proxy) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, " Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0 .2564.109 Safari/537.36"); curl_setopt($ch, CURLOPT_PROXY, $proxy); curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_CURLPROXY_SOCKS5); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_ENCODING, ""); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_REFERER, 'http://google.ru'); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_MAXREDIRS, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); $output = curl_exec($ch); curl_close($ch); return $output; } И вызов $file = 'proxy_socks_ip.txt'; $arr = file($file); $count = count($arr); for ($i = 0; $i < $count; $i++) { $auth = curl($link, $arr[$i]); } 

The file has 1000 proxies. Question: how to make sure that the working proxy is checked in the cycle, and if so, to continue working, if not, weed it out?

  • This is not a freelance site. - AK
  • What algorithm do you see? - AK
  • thought ............................. $ output = curl_exec ($ ch); if ($ output) {curl_close ($ ch); return $ output;} else curl_close ($ ch); return false} But does not go - Roma Tulaydan
  • In your version of the wild brakes will be. When curl tries to read a file each time and bypass in a loop to the first working proxy. Imagine that the first 905 proxies are non-working. On each request, re-parse the file, and then wait 905 timeouts until the 906 proxy responds. No, ok? - AK
  • You need to think about the fact that you need to store information about the selected proxy somewhere, in an amicable way - also keep information on the date of the last check on all proxies. We need to think about how to do checks - on a schedule or when you need to do a request. - AK

0