Python的`urllib2`:为什么我使用`urlopen`打开维基百科页面时会出现403错误?
Python的`urllib2`:为什么我使用`urlopen`打开维基百科页面时会出现403错误?
我在尝试从维基百科打开一个特定页面时遇到了一个奇怪的错误。这是页面的链接:http://en.wikipedia.org/wiki/OpenCola_(drink)。这是命令行会话的内容:
f = urllib2.urlopen('http://en.wikipedia.org/wiki/OpenCola_(drink)')
Traceback (most recent call last):
File "C:\Program Files\Wing IDE 4.0\src\debug\tserver\_sandbox.py", line 1, in
# Used internally for debug sandbox under external interpreter
File "c:\Python26\Lib\urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "c:\Python26\Lib\urllib2.py", line 397, in open
response = meth(req, response)
File "c:\Python26\Lib\urllib2.py", line 510, in http_response
'http', request, response, code, msg, hdrs)
File "c:\Python26\Lib\urllib2.py", line 435, in error
return self._call_chain(*args)
File "c:\Python26\Lib\urllib2.py", line 369, in _call_chain
result = func(*args)
File "c:\Python26\Lib\urllib2.py", line 518, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden
这在两个不同的系统和不同的大陆上都发生过。有人知道为什么会出现这种情况吗?