HTTP::ProxySelector - Perl extension for automatically setting an anonymous proxy
use HTTP::ProxySelector; use LWP::UserAgent; # Instanciate my $selector = HTTP::ProxySelector->new(); my $ua = LWP::UserAgent->new(); # Assign an anonymous proxy to the UserAgent object. $selector->set_proxy($ua); # Just in case you need to know the chosen proxy print 'Selected proxy: ',$selector->get_proxy(),"\n";
Automatically selects you an anonymous proxy for use of your UserAgent instance. Just hand it your favorite proxy list site, or use the defaults. The package will then use your existing useragent instance to access the site and set it's proxy settings according to a random entry in the list.
new is the constructor for HTTP::ProxySelector objects
- Accepts an Key-Value list with the list attributes.
Key: sites - Reference to a list of sites containing the proxy lists. Example : $select = HTTP::ProxySelector->new(sites => ['http://www.proxylist.com/list.htm']); Default - http://www.multiproxy.org/txt_anon/proxy.txt http://www.samair.ru/proxy/fresh-proxy-list.htm
Key: testflag - Flag indicating whether the randomly selected proxy should be checked. Example : $select = HTTP::ProxySelector->new(testflag => 0); Default - 1. num_tries - Number of proxies you wish to test before giving up. Example : $select = HTTP::ProxySelector->new(num_tries => 10); Default - 5. testsite - Destination site to test the proxy with. Example : $select = HTTP::ProxySelector->new(testsite => 'http://yahoo.com'); Default - http://www.google.com
$result = $select->set_proxy($useragent);
Assign anonymous proxy to the useragent proxy
0 on success, a string describing the error upon failure
$proxy = $select->get_proxy();
Extract the address of the currently selected proxy.
String, describing the address of the proxy.
None by default.
This is becoming a dangerous habbit, but testing should really be implemented sometime soon.
Eyal Udassin, <email@example.com>