提出HTTPError(req.get_full_url(),code,msg,hdrs,fp)

时间:2016-09-12 10:17:48

标签: python-2.7 urllib2

我尝试在Python中阅读此网址 - http://malc0de.com/bl/BOOT

Traceback (most recent call last):
  File "C:\Android\android_workspace\pro2\test.py", line 2, in <module>
    threats = urllib2.urlopen("http://malc0de.com/bl/BOOT")
  File "C:\Python27\lib\urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Python27\lib\urllib2.py", line 437, in open
    response = meth(req, response)
  File "C:\Python27\lib\urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python27\lib\urllib2.py", line 475, in error
    return self._call_chain(*args)
  File "C:\Python27\lib\urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "C:\Python27\lib\urllib2.py", line 558, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden

但我收到了这个错误:

{{1}}

我该怎么做才能解决它?

1 个答案:

答案 0 :(得分:0)

这是与python或urllib无关的HTTP错误。它说,出于某种原因,您不能查看此特定页面。

在我看来,网站所有者过滤机器人/抓取工具的访问权限,因为我可以在Firefox中打开它,但不能通过urllib打开它。它可能会根据用户代理进行过滤,可能会更改,请参阅Changing user agent on urllib2.urlopen,尽管这可能是不礼貌。