Making urllib2 work with proxy urls

A

Anand Pillai

My company uses an automatic proxy configuration url of the form
http://server.company.com/department/proxy.pac .

I have made urllib2 work with normal proxies/firewalls, even the ones
requiring authentication, but I am stuck with this problem.

I tried getting the actual proxy server IP and configuring urllib2
with the normal way it works with proxies, but it has not worked
for me.

Any suggestions are welcome.

Thanks

-Anand
 
S

simo

My company uses an automatic proxy configuration url of the form
http://server.company.com/department/proxy.pac .

I have made urllib2 work with normal proxies/firewalls, even the ones
requiring authentication, but I am stuck with this problem.

I tried getting the actual proxy server IP and configuring urllib2
with the normal way it works with proxies, but it has not worked
for me.

The pac file is usually just a script with the config data for
browsers, it will return something like "PROXY
http-proxy.mydomain.com:80"

I very much doubt urllib2 can actually proces the .pac file.

You should be able to open that file and figure out what you need to
set the proxy variable to in urllib2 (or your ENVironment).

urllib just "automagically" works through proxies, not sure about
2....
 
J

JanC

(e-mail address removed) (simo) schreef:
The pac file is usually just a script with the config data for
browsers, it will return something like "PROXY
http-proxy.mydomain.com:80"

I very much doubt urllib2 can actually proces the .pac file.

You should be able to open that file and figure out what you need to
set the proxy variable to in urllib2 (or your ENVironment).

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top