Fix google search not working because of change in website markup

This commit is contained in:
Kovid Goyal 2020-12-24 09:47:53 +05:30
parent 2a66dfead0
commit 7c8672f2ee
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -20,7 +20,7 @@ from calibre import browser as _browser, prints, random_user_agent
from calibre.utils.monotonic import monotonic
from calibre.utils.random_ua import accept_header_for_ua
current_version = (1, 0, 4)
current_version = (1, 0, 5)
minimum_calibre_version = (2, 80, 0)
@ -235,7 +235,7 @@ def google_search(terms, site=None, br=None, log=prints, safe_search=False, dump
ans = []
for div in root.xpath('//*[@id="search"]//*[@id="rso"]//*[@class="g"]'):
try:
a = div.xpath('descendant::div[@class="r"]/a[@href]')[0]
a = div.xpath('descendant::div[@class="rc"]//a[@href]')[0]
except IndexError:
log('Ignoring div with no descendant')
continue