What errors/exceptions do I need to handle with urllib2.Request / urlopen?

前端 未结 5 1834
别那么骄傲
别那么骄傲 2020-12-04 09:28

I have the following code to do a postback to a remote URL:

request = urllib2.Request(\'http://www.example.com\', postBackData, { \'User-Agent\' : \'My User          


        
5条回答
  •  情书的邮戳
    2020-12-04 10:18

    I catch:

    httplib.HTTPException
    urllib2.HTTPError
    urllib2.URLError
    

    I believe this covers everything including socket errors.

提交回复
热议问题