http://qs321.pair.com?node_id=646469

hacker has asked for the wisdom of the Perl Monks concerning the following question:

I have a tool I'm writing which requires the randomization across a list of proxies. I'm doing that with:

my @proxies = read_file('proxies'); my $random_proxy = $proxies[rand @proxies]; $ua->proxy(['http', 'ftp'], "http://$random_proxy");

This works great, EXCEPT when I try to use one of those proxies, and it is either down, or giving me a 500, 403 or other status indicating that I can't use it for proxying.

Is there some programatic way of querying a proxy server to determine if it will allow itself to be used, and if not, skip to the next $random_proxy in the list?

I was thinking that testing $res->status_line after a HEAD test on it might work, but even if the IP is accessible, does that mean the proxy can be used? I don't think so.

Has anyone tried something like this? I need to be sure my list of proxies is only pointing to those which can be used as a public proxy.

Thanks!