Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2024-04-23 12:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found