mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Get Books: Fix extraction of price data from amazon.com search results
This commit is contained in:
parent
38012bd21c
commit
db1c0a117b
@ -3,7 +3,7 @@
|
||||
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
store_version = 17 # Needed for dynamic plugin loading
|
||||
store_version = 18 # Needed for dynamic plugin loading
|
||||
|
||||
from contextlib import closing
|
||||
try:
|
||||
@ -74,7 +74,12 @@ def search_amazon(query, max_results=10, timeout=60,
|
||||
aparts = etree.tostring(adiv, method='text', encoding='unicode').split()
|
||||
idx = aparts.index('|')
|
||||
author = ' '.join(aparts[1:idx])
|
||||
price = ''.join(result.xpath('.//span[contains(@class, "a-price")]/span[contains(@class, "a-offscreen")]/text()'))
|
||||
price = ''
|
||||
for span in result.xpath('.//span[contains(@class, "a-price")]/span[contains(@class, "a-offscreen")]'):
|
||||
q = ''.join(span.xpath('./text()'))
|
||||
if q:
|
||||
price = q
|
||||
break
|
||||
|
||||
counter -= 1
|
||||
|
||||
@ -120,6 +125,5 @@ class AmazonKindleStore(StorePlugin):
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
|
||||
for result in search_amazon(' '.join(sys.argv[1:]), write_html_to='/t/amazon.html'):
|
||||
print(result)
|
||||
|
Loading…
x
Reference in New Issue
Block a user