urllib2.HTTPError: HTTP Error 404: not Found für die gültige url

Ich bin mit einem python-opengraph-Bibliothek zum analysieren einer website opengraph-tags https://github.com/erikriver/opengraph.

import opengraph
url = 'http://www.foxnews.com/world/2014/10/20/uk-gun-owners-now-subject-to-warrantless-home-searches/'
og = opengraph.OpenGraph(url=url)
print og.to_json()

Wenn ich dieses Skript ausführen, erhalte ich die Fehlermeldung

Traceback (most recent call last):
  File "test.py", line 16, in <module>
    raw = urllib2.urlopen(url)
  File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 410, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 448, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 531, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found

urllib2 unter die Haube zu greifen, die html, bevor es analysiert wird, https://github.com/erikriver/opengraph/blob/master/opengraph/opengraph.py#L50-L52

Warum erhalte ich dieses Fehlermeldung 404? Ich kann auf diese url aus meinem browser und auch abrufen der open graph tags für diese url mit dieser php-Bibliothek https://github.com/scottmac/opengraph.

Die python-Bibliothek ist in der Lage, zum abrufen der open graph tags für alle anderen urls, aber diese url scheint zu sein, eine Anomalie.

InformationsquelleAutor user784637 | 2014-10-26
Schreibe einen Kommentar