Skip to content

Commit

Permalink
Merge pull request #2779 from internetarchive/hotfix/bwb-urllib2
Browse files Browse the repository at this point in the history
hotfixing urllib2 + bwb API
  • Loading branch information
mekarpeles authored Dec 27, 2019
2 parents 16c3e6c + d15e47f commit 4ba4afd
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions openlibrary/core/vendors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import web
import urllib2
import simplejson
import requests
from amazon.api import SearchException
from infogami import config
from infogami.utils.view import public
Expand All @@ -13,7 +14,7 @@
from openlibrary import accounts


BETTERWORLDBOOKS_API_URL = 'http://products.betterworldbooks.com/service.aspx?ItemId='
BETTERWORLDBOOKS_API_URL = 'https://products.betterworldbooks.com/service.aspx?ItemId='
AMAZON_FULL_DATE_RE = re.compile('\d{4}-\d\d-\d\d')
ISBD_UNIT_PUNCT = ' : ' # ISBD cataloging title-unit separator punctuation

Expand Down Expand Up @@ -291,10 +292,8 @@ def _get_betterworldbooks_metadata(isbn):

url = BETTERWORLDBOOKS_API_URL + isbn
try:
req = urllib2.Request(url)
f = urllib2.urlopen(req)
response = f.read()
f.close()
r = requests.get(url)
response = r.content
product_url = re.findall("<DetailURLPage>\$(.+)</DetailURLPage>", response)
new_qty = re.findall("<TotalNew>([0-9]+)</TotalNew>", response)
new_price = re.findall("<LowestNewPrice>\$([0-9.]+)</LowestNewPrice>", response)
Expand Down

0 comments on commit 4ba4afd

Please sign in to comment.