Deanznet Posted December 11, 2009 Share Posted December 11, 2009 Okay here is the thing... i know how to add proxys curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); curl_setopt($ch, CURLOPT_PROXY,"[i][b]PROXYHERE[/b][/i]"); Here are my questions.. What kind of proxy dose it use? ( Sock5? http? Sock4? ect..) Okay second here the php part. I need it to read a txt file on the server called proxylist.txt and randomly pick a proxy from it but after it picks it. it has to remove it from the TXT file. Help!?@! Quote Link to comment https://forums.phpfreaks.com/topic/184741-curl-proxy/ Share on other sites More sharing options...
btherl Posted December 11, 2009 Share Posted December 11, 2009 Since you set the proxy type to HTTP, I would assume it will use an HTTP proxy. There is documentation for curl_setopt here. For your second question, that sounds awkward. What problem are you trying to solve by using that text file? Quote Link to comment https://forums.phpfreaks.com/topic/184741-curl-proxy/#findComment-975270 Share on other sites More sharing options...
Deanznet Posted December 11, 2009 Author Share Posted December 11, 2009 Because i cant use the same Proxy again thats why it has to be removed from the txt file. Quote Link to comment https://forums.phpfreaks.com/topic/184741-curl-proxy/#findComment-975277 Share on other sites More sharing options...
premiso Posted December 11, 2009 Share Posted December 11, 2009 The text file portion is actually really easy: <?php $proxyArr = file('proxies.txt'); $randProxy = array_rand($proxyArr); $proxy = $proxyArr[$randProxy]; unset($proxyArr[$randProxy]); $fh = fopen('proxies.txt', 'w+'); foreach ($proxyArr as $write) fwrite($fh, $write); fclose($fh); // other code here echo $proxy; ?> If you are using a database it is actually quite a bit easier then that. Quote Link to comment https://forums.phpfreaks.com/topic/184741-curl-proxy/#findComment-975627 Share on other sites More sharing options...
btherl Posted December 14, 2009 Share Posted December 14, 2009 If you want to remove the proxy from the text file, the simplest is probably to read in the entire file, filtering for that proxy server as you go, then writing the entire file again. Or you can filter while writing instead of while reading. Quote Link to comment https://forums.phpfreaks.com/topic/184741-curl-proxy/#findComment-976728 Share on other sites More sharing options...
Deoctor Posted December 14, 2009 Share Posted December 14, 2009 as the other users already told it is quite risky to use the text file.use a database instead and make a column so that u can make it as 1 once u use it off. <? //$url = 'http://www.whatismyip.com/'; $url='http://www.ip-adress.com/what_is_my_ip/'; $cUrl = curl_init(); curl_setopt($cUrl,CURLOPT_VERBOSE,1); //curl_setopt($cUrl,CURLOPT_HTTPPROXYTUNNEL,true); curl_setopt($cUrl,CURLOPT_PROXYTYPE,CURLPROXY_HTTP); curl_setopt($cUrl,CURLOPT_PROXY,'208.43.64.236:808'); curl_setopt($cUrl,CURLOPT_SSL_VERIFYPEER,false); curl_setopt($cUrl,CURLOPT_URL,$url); curl_setopt($cUrl,CURLOPT_TIMEOUT,320); $PageContent = curl_exec($cUrl); curl_close($cUrl); echo $PageContent; ?> so at the proxy number which i have specified u can use the random one. Quote Link to comment https://forums.phpfreaks.com/topic/184741-curl-proxy/#findComment-976787 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.