471,065 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,065 software developers and data experts.

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)
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/
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?


Jul 18 '05 #1
0 1332

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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.