Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #89942

urllib2.urlopen error "socket.error: [Errno 104] Connection reset by peer"

From "Jia CHEN" <jia.j.chen@foxmail.com>
Subject urllib2.urlopen error "socket.error: [Errno 104] Connection reset by peer"
Date 2015-05-05 10:41 +0800
Newsgroups comp.lang.python
Message-ID <mailman.109.1430793765.12865.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi There,
 
I have the error below when trying to download the html content of a webpage. I can open this webpage in a browser without any problem. I am using Ubuntu 14.04. Could you give me come clues about what is happening and how to solve the issue? Thanks.
 
$python 
 
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
 
[GCC 4.8.2] on linux2
 
Type "help", "copyright", "credits" or "license" for more information.
 
>>> import urllib2
 
request = urllib2.Request('http://guggenheiminvestments.com/products/etf/gsy/holdings')
 
response = urllib2.urlopen(request)
 
>>> >>> Traceback (most recent call last):
 
File "<stdin>", line 1, in <module>
 
File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
 
return _opener.open(url, data, timeout)
 
File "/usr/lib/python2.7/urllib2.py", line 404, in open
 
response = self._open(req, data)
 
File "/usr/lib/python2.7/urllib2.py", line 422, in _open
 
'_open', req)
 
File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
 
result = func(*args)
 
File "/usr/lib/python2.7/urllib2.py", line 1214, in http_open
 
return self.do_open(httplib.HTTPConnection, req)
 
File "/usr/lib/python2.7/urllib2.py", line 1187, in do_open
 
r = h.getresponse(buffering=True)
 
File "/usr/lib/python2.7/httplib.py", line 1045, in getresponse
 
response.begin()
 
File "/usr/lib/python2.7/httplib.py", line 409, in begin
 
version, status, reason = self._read_status()
 
File "/usr/lib/python2.7/httplib.py", line 365, in _read_status
 
line = self.fp.readline(_MAXLINE + 1)
 
File "/usr/lib/python2.7/socket.py", line 476, in readline
 
data = self._sock.recv(self._rbufsize)
 
socket.error: [Errno 104] Connection reset by peer
 
>>>

Best,

Jia CHEN

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

urllib2.urlopen error "socket.error: [Errno 104] Connection reset by peer" "Jia CHEN" <jia.j.chen@foxmail.com> - 2015-05-05 10:41 +0800

csiph-web