Python's `urllib2`: Why do I get error 403 when I `urlopen` a Wikipedia page?

前端 未结 6 1191
轻奢々
轻奢々 2020-12-07 11:07

I have a strange bug when trying to urlopen a certain page from Wikipedia. This is the page:

http://en.wikipedia.org/wiki/OpenCola_(drink)

This

6条回答
  •  醉话见心
    2020-12-07 11:29

    To debug this, you'll need to trap that exception.

    try:
        f = urllib2.urlopen('http://en.wikipedia.org/wiki/OpenCola_(drink)')
    except urllib2.HTTPError, e:
        print e.fp.read()
    

    When I print the resulting message, it includes the following

    "English

    Our servers are currently experiencing a technical problem. This is probably temporary and should be fixed soon. Please try again in a few minutes. "

提交回复
热议问题