Merge branch 'search_engine_google_1750692' of https://github.com/cgaspar/calibre

Fixes #1750692 [Amazon metadata plugin error](https://bugs.launchpad.net/calibre/+bug/1750692)
This commit is contained in:
Kovid Goyal 2018-02-21 07:55:39 +05:30
commit 0fbb1a3e58
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -230,7 +230,11 @@ def google_search(terms, site=None, br=None, log=prints, safe_search=False, dump
root = query(br, url, 'google', dump_raw, timeout=timeout)
ans = []
for div in root.xpath('//*[@id="search"]//*[@id="rso"]//*[@class="g"]'):
try:
a = div.xpath('descendant::h3[@class="r"]/a[@href]')[0]
except IndexError:
log('Ignoring div with no descendant')
continue
title = tostring(a)
try:
c = div.xpath('descendant::div[@class="s"]//a[@class="fl"]')[0]