set_proxy in urllib2 is driving my crazy

est electronixtar at gmail.com
Mon Jul 23 11:50:17 CEST 2007


A simple py script

import urllib2
req=urllib2.Request("http://www.google.com")
req.set_proxy("127.0.0.1:1","http")
print urllib2.urlopen(req).read()




Here is error:

 "C:\Python25\python.exe" -u "E:\Python\Crawler\test.py"


Traceback (most recent call last):
  File "E:\Python\Crawler\test.py", line 4, in <module>
    print urllib2.urlopen(req).read()
  File "C:\Python25\lib\urllib2.py", line 121, in urlopen
    return _opener.open(url, data)
  File "C:\Python25\lib\urllib2.py", line 374, in open
    response = self._open(req, data)
  File "C:\Python25\lib\urllib2.py", line 392, in _open
    '_open', req)
  File "C:\Python25\lib\urllib2.py", line 353, in _call_chain
    result = func(*args)
  File "C:\Python25\lib\urllib2.py", line 1101, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "C:\Python25\lib\urllib2.py", line 1076, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error (10054, 'Connection reset by peer')>


I built a proxy with CCproxy 6.3.2 on my own machine, and it's working
absolutely all right, but how can my simple python script go wrong ?




More information about the Python-list mailing list