Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!news.roellig-ltd.de!open-news-network.org!border2.nntp.ams1.giganews.com!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:error': 0.03; 'subject:: [': 0.04; 'subject:reset': 0.07; 'http': 0.09; 'indicates': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:peer': 0.09; 'windows': 0.15; 'letting': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:skip:u 10': 0.16; 'looked': 0.18; 'trying': 0.19; 'subject:] ': 0.20; '(the': 0.22; 'reset': 0.22; 'header:User- Agent:1': 0.23; 'error': 0.23; 'header': 0.24; '(see': 0.26; 'header:X-Complaints-To:1': 0.27; 'writes:': 0.31; 'open': 0.33; 'problem.': 0.35; 'done': 0.36; 'charset:us-ascii': 0.36; 'server': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'subject:"': 0.60; 'browser': 0.61; 'received:217': 0.63; 'provide': 0.64; 'side': 0.67; 'between': 0.67; 'webpage': 0.68; 'request.': 0.70; 'connection.': 0.74; '(script)': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: dieter Subject: Re: urllib2.urlopen error "socket.error: [Errno 104] Connection reset by peer" Date: Wed, 13 May 2015 07:55:23 +0200 References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Gmane-NNTP-Posting-Host: pd9e08599.dip0.t-ipconnect.de User-Agent: Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux) Cancel-Lock: sha1:neE71cHz7Io+oCvWMZM6yaSTmz0= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1431496532 news.xs4all.nl 2953 [2001:888:2000:d::a6]:40856 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90528 "Jia CHEN" 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).