erikriver / opengraph

A python module to parse the Open Graph Protocol
http://ogp.me/
MIT License
226 stars 82 forks source link

replace urllib2 by requests #15

Open waynehuangplus opened 9 years ago

waynehuangplus commented 9 years ago

Hi, I use python python 2.7.9 and it will an error, and I found it may due to SSL verification in Python 2.7.9 from some discussion https://github.com/HenriWahl/Nagstamon/issues/126#issuecomment-67765841.

I replace urllib2 by requests to make sure it works in python2.7 in this PR.

Traceback (most recent call last): File "./og.py", line 5, in video = opengraph.OpenGraph(url="http://www.youtube.com/watch?v=q3ixBmDzylQ") File "/usr/local/lib/python2.7/site-packages/opengraph/opengraph.py", line 36, in init self.fetch(url) File "/usr/local/lib/python2.7/site-packages/opengraph/opengraph.py", line 50, in fetch raw = urllib2.urlopen(url) File "/usr/local/lib/python2.7/urllib2.py", line 154, in urlopen return opener.open(url, data, timeout) File "/usr/local/lib/python2.7/urllib2.py", line 437, in open response = meth(req, response) File "/usr/local/lib/python2.7/urllib2.py", line 550, in http_response 'http', request, response, code, msg, hdrs) File "/usr/local/lib/python2.7/urllib2.py", line 469, in error result = self._call_chain(_args) File "/usr/local/lib/python2.7/urllib2.py", line 409, in _call_chain result = func(_args) File "/usr/local/lib/python2.7/urllib2.py", line 656, in http_error_302 return self.parent.open(new, timeout=req.timeout) File "/usr/local/lib/python2.7/urllib2.py", line 431, in open response = self._open(req, data) File "/usr/local/lib/python2.7/urllib2.py", line 449, in _open '_open', req) File "/usr/local/lib/python2.7/urllib2.py", line 409, in _call_chain result = func(*args) File "/usr/local/lib/python2.7/urllib2.py", line 1240, in https_open context=self._context) File "/usr/local/lib/python2.7/urllib2.py", line 1197, in do_open raise URLError(err) urllib2.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)>