TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-18-2010, 02:35 AM   #1 (permalink)
The Visitor
 
Join Date: Jun 2010
Posts: 3
Thanks: 0
soma56 is on a distinguished road
Default How to get radom proxies from an simple html page and place them in cURL for parsing!

Well, I've taken a crash course on cURL and learned how to successfully parse through proxies. I can strip html as well. Not bad considering I thought PHP was a cough syrup medicine a month ago. Now I'd like to rotate those proxies. Let's assume I have can get a list of proxies on an html page that are separated by a <br /> tag. How would I go about going there and grabbing a random proxy from the list?

I'm assuming I'll have to use either cURL or file_get_contents. Hopefully the example below will give you a better understanding of what I'm trying to do:

Code:
$proxypage = file_get_contents('myproxylist.html');

$proxy = "An ARRAY of the proxylist?";

$rand_proxy = ("randomly grab from ARRAY?", $proxy);


$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL, $url);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl_handle,CURLOPT_PROXY, "$rand_proxy");
curl_setopt($curl_handle, CURLOPT_TIMEOUT, 100);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
I guess the next question would be, as I'll be using proxies with this program over and over again within a short time - would I have to download, create and array and choose a random proxy every single time or is there a more efficient way?
soma56 is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 05:08 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design