Making urllib2 work with proxy urls

Tony Meyer t-meyer at ihug.co.nz
Tue Apr 13 22:24:43 EDT 2004


> A PAC file is a script that defines a JavaScript function:
> 
> function FindProxyForURL(url, host) {
>     // based on url & host:
>     // return "DIRECT" to use no proxy, or something like
>     // return "PROXY proxy.example.com:8080" to use that proxy }
> 
> This function can get quite complex, so to use it 
> automaticly, you might need a JavaScript engine...

I looked into this a little for SpamBayes a while back (there's still an
open bug report...) and it's unfortunately even more complex than that.  The
automatic configuration javascript has access to some special functions that
IE (etc) provide, so you'd need access to them as well, or for the OP to
write their own versions of them (they're for dealing with IP ranges and
that sort of thing).

There's quite good documentation about it around, though, so it's easy to
start.  My suggestion would be that the OP look at the Mozilla code, since
Firefox (and I presume Mozilla) can use automatic configuration scripts, and
the source is somewhat easier to get hold of than the source to IE...

=Tony Meyer





More information about the Python-list mailing list