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


Groups > comp.lang.python > #90528

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

From dieter <dieter@handshake.de>
Subject Re: urllib2.urlopen error "socket.error: [Errno 104] Connection reset by peer"
Date 2015-05-13 07:55 +0200
References <tencent_2B2ADFEE54D112343708D73B@qq.com>
Newsgroups comp.lang.python
Message-ID <mailman.431.1431496532.12865.python-list@python.org> (permalink)

Show all headers | View raw


"Jia CHEN" <jia.j.chen@foxmail.com> writes:

> 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.

"Connection reset by peer" means that the other side (the HTTP server
in your case) has closed the connection.

It may have looked at the "User-Agent" request header to differentiate
between a browser request and an automated (script) request.

To work around this, you may provide a "User-Agent" header
to your "urllib2.Request" (see the documentation) letting
the "User-Agent" to look as if the request had been done by a browser
("Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"
indicates a firefoy).

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


Thread

Re: urllib2.urlopen error "socket.error: [Errno 104] Connection reset by peer" dieter <dieter@handshake.de> - 2015-05-13 07:55 +0200

csiph-web