diff --git a/opengraph/opengraph.py b/opengraph/opengraph.py index 9cedb97..58f98a8 100644 --- a/opengraph/opengraph.py +++ b/opengraph/opengraph.py @@ -1,7 +1,7 @@ # encoding: utf-8 import re -import urllib2 +import requests try: from bs4 import BeautifulSoup except ImportError: @@ -47,8 +47,8 @@ def __getattr__(self, name): def fetch(self, url): """ """ - raw = urllib2.urlopen(url) - html = raw.read() + raw = requests.get(url) + html = raw.text return self.parser(html) def parser(self, html): @@ -123,4 +123,4 @@ def scrape_url(self, doc): def scrape_description(self, doc): tag = doc.html.head.findAll('meta', attrs={"name":"description"}) result = "".join([t['content'] for t in tag]) - return result \ No newline at end of file + return result diff --git a/setup.py b/setup.py index 9d1677e..71c21fa 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,8 @@ include_package_data=True, zip_safe=False, install_requires=[ - 'beautifulsoup4' + 'beautifulsoup4', + 'requests' ], entry_points=""" # -*- Entry points: -*-