diff --git a/oml/meta/amazon.py b/oml/meta/amazon.py index 4f8c230..da8806a 100644 --- a/oml/meta/amazon.py +++ b/oml/meta/amazon.py @@ -13,13 +13,14 @@ def info(key, value): value = stdnum.isbn.to_isbn10(value) if len(value) != 10: raise IOError('invalid isbn %s' % value) - url = 'http://www.amazon.com/dp/' + value data = read_url(url).decode() doc = lxml.html.document_fromstring(data) info = {} if '404 - Document Not Found' in data: return info + if 'To discuss automated access to Amazon data please' in data: + return info for l in doc.xpath('//link[@rel="canonical" and @href]'): info['asin'] = [l.get('href').rpartition('/')[-1]] break