468,132 Members | 1,553 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,132 developers. It's quick & easy.

using a proxy with urllib2

I'm using python2.2.2 on redhat linux 7.3

Here's a snippet of what I'm trying to run:

# set up proxy
import urllib2
proxy_support = urllib2.ProxyHandler({"http":"http://webproxy.mycompany.com:3128"})
#proxy_support = urllib2.ProxyHandler()
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)
f = urllib2.urlopen('http://some.site.com/')
print f.read(1000)

This code times out and throws a socket connection error. I've also tried setting my environment variable: http_proxy=http://webproxy.mycompany.com:3128 and using the default form of ProxyHandler.

I'm certain the proxy info is correct (and a proxy is needed) because I can use lynx to get it to work:

env http_proxy=http://webproxy.mycompany.com:3128 lynx http://some.site.com/
or
export http_proxy=http://webproxy.mycompany.com:3128
lynx http://some.site.com/

Without the proxy info defined for lynx it won't connect to the site in question.

Any ideas what might be tripping me up?

dustin

Jul 18 '05 #1
0 1281

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by O. Koch | last post: by
2 posts views Thread by Andre Bocchini | last post: by
4 posts views Thread by bmiras | last post: by
4 posts views Thread by Fuzzyman | last post: by
1 post views Thread by Ray Slakinski | last post: by
3 posts views Thread by itay_k | last post: by
6 posts views Thread by Jack | last post: by
1 post views Thread by Magnus.Moraberg | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.