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!


In reply to Testing proxy "health" by hacker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.