File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22import web
33import urllib2
44import simplejson
5+ import requests
56from amazon .api import SearchException
67from infogami import config
78from infogami .utils .view import public
1314from openlibrary import accounts
1415
1516
16- BETTERWORLDBOOKS_API_URL = 'http ://products.betterworldbooks.com/service.aspx?ItemId='
17+ BETTERWORLDBOOKS_API_URL = 'https ://products.betterworldbooks.com/service.aspx?ItemId='
1718AMAZON_FULL_DATE_RE = re .compile ('\d{4}-\d\d-\d\d' )
1819ISBD_UNIT_PUNCT = ' : ' # ISBD cataloging title-unit separator punctuation
1920
@@ -291,10 +292,8 @@ def _get_betterworldbooks_metadata(isbn):
291292
292293 url = BETTERWORLDBOOKS_API_URL + isbn
293294 try :
294- req = urllib2 .Request (url )
295- f = urllib2 .urlopen (req )
296- response = f .read ()
297- f .close ()
295+ r = requests .get (url )
296+ response = r .content
298297 product_url = re .findall ("<DetailURLPage>\$(.+)</DetailURLPage>" , response )
299298 new_qty = re .findall ("<TotalNew>([0-9]+)</TotalNew>" , response )
300299 new_price = re .findall ("<LowestNewPrice>\$([0-9.]+)</LowestNewPrice>" , response )
You can’t perform that action at this time.
0 commit comments