0

I write this python code:

import socks
import socket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "64.83.219.7", 58279)
socket.socket = socks.socksocket
socket.setdefaulttimeout(19)
import urllib2
print urllib2.urlopen('http://www.google.com').read()

but when I execute it, I get this error:

urllib2.URLError: <urlopen error timed out>

What am I doing wrong?

SilentGhost
322k67 gold badges312 silver badges294 bronze badges
asked May 11, 2010 at 11:31
2
  • apparently urlopen times out. Commented May 11, 2010 at 11:35
  • Might want to check if you are able to establish this connection using your SOCKS proxy outside of Python first, then worry about whether there is a problem with your code or not. Commented May 11, 2010 at 18:25

1 Answer 1

2

Something timed out in your script. I guess the connection to google because of wrong proxy setup. I think your goal is to fetch the contents of http://www.google.com through a proxy? I don't know about this method to set it using socket/socks module. Maybe you want to take a look at the following chapters in the python documentation:

http://docs.python.org/library/urllib2.html?highlight=urllib2#examples (code sinppet 5 and the text above)

http://docs.python.org/library/urllib2.html?highlight=urllib2#urllib2.Request.set_proxy

http://docs.python.org/library/urllib2.html?highlight=urllib2#proxyhandler-objects

answered May 11, 2010 at 12:09
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.