in reply to lwp proxy problem
I downloaded the file using wget, getting:
$ wget -O - http://www.tau.ac.il/tau.pac --17:49:19-- http://www.tau.ac.il/tau.pac => `-' Resolving www.tau.ac.il... 132.66.16.6 Connecting to www.tau.ac.il[132.66.16.6]:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1,187 [application/x-ns-proxy-autoconfig] 0% [ ] 0 --.--K/s +function FindProxyForURL(url, host) { if ((isInNet(myIpAddress(), "132.66.90.0", "255.255.254.0")) & +& !dnsDomainIs(host, "www.tau.ac.il")) { return "PROXY proxyslb.tau.ac.il:8080; " + "PROXY proxy.tau.ac.il:8080; " + "PROXY netcache.tau.ac.il:8080; " + "PROXY netcache2.tau.ac.il:8080; " + "PROXY proxym.tau.ac.il:8080; " + "PROXY 132.66.16.12:8080; " + "PROXY 132.66.16.34:8080; " + "PROXY 132.66.16.23:8080"; } else if (isInNet(host, "132.66.58.20", "255.255.255.255")) { return "PROXY proxym.tau.ac.il:8080"; } else if (isPlainHostName(host) || isInNet(host, "127.0.0.1", "255.255.255.255") || isInNet(host, "132.66.0.0", "255.254.0.0")) { return "DIRECT"; } else { return "PROXY proxyslb.tau.ac.il:8080; " + "PROXY proxy.tau.ac.il:8080; " + "PROXY netcache.tau.ac.il:8080; " + "PROXY netcache2.tau.ac.il:8080; " + "PROXY proxym.tau.ac.il:8080; " + "PROXY 132.66.16.12:8080; " + "PROXY 132.66.16.34:8080; " + "PROXY 132.66.16.23:8080"; } }
It is easy to read, so I think that once you know your IP address you can pick a proxy from the list by hand
Or you can write a script yourself to parse the pac file, at the moment I have no time to sketch one, sorry :-(
Update: see HTTP::ProxyAutoConfig
Update: try this and tell me if it works. It seems I can't use that proxy, so I couldn't make any test myself, apart from checking that it parses and runs correctly.
use HTTP::ProxyAutoConfig ; use LWP::Simple qw(&getstore $ua); + my $pac = new HTTP::ProxyAutoConfig("http://www.tau.ac.il/tau.pac"); + my $url='http://www.yahoo.com'; $ua->proxy(http => $pac->FindProxy($url)); + my $file='test.html'; print "success" if (getstore($url, $file));
Update: actually, that won't work, since you need to parse the return value from FindProxy and pass it to $ua->proxy only if it matches /PROXY: host:port/ (after cleaning up the PROXY: parts, of course). Unfortunately, I am having no luck in making this module work (the FindProxyForURL function doesn't get defined). I'll update the above script as soon as I make sense of the module...
Update: Ok, I checked with ptkdb and saw that:
Possible solutions:
Sorry, I can't help further :-(
Ciao!
--bronto
The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).
--John M. Dlugosz
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: lwp proxy problem
by dannoura (Pilgrim) on Apr 27, 2004 at 16:15 UTC |