mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-01-06 15:25:05 +01:00
Get Books: Fix extraction of price data from amazon.com search results
This commit is contained in:
parent
38012bd21c
commit
db1c0a117b
1 changed files with 7 additions and 3 deletions
|
|
@ -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 asbytes(x):
|
|||
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 @@ def get_details(self, search_result, timeout):
|
|||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
|
||||
for result in search_amazon(' '.join(sys.argv[1:]), write_html_to='/t/amazon.html'):
|
||||
print(result)
|
||||
|
|
|
|||
Loading…
Reference in a new issue