mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix getting search results from google broken because of markup changes
This commit is contained in:
parent
4b0745052d
commit
3446f3b5d3
@ -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, 6)
|
||||
current_version = (1, 0, 7)
|
||||
minimum_calibre_version = (2, 80, 0)
|
||||
|
||||
|
||||
@ -233,13 +233,13 @@ 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="rc"]//a[@href]')[0]
|
||||
a = div.xpath('descendant::a[@href]')[0]
|
||||
except IndexError:
|
||||
log('Ignoring div with no descendant')
|
||||
log('Ignoring div with no main result link')
|
||||
continue
|
||||
title = tostring(a)
|
||||
try:
|
||||
c = div.xpath('descendant::*[@role="menu"]//a[@class="fl"]')[0]
|
||||
c = div.xpath('descendant::*[@role="menuitem"]//a[@class="fl"]')[0]
|
||||
except IndexError:
|
||||
log('Ignoring {!r} as it has no cached page'.format(title))
|
||||
continue
|
||||
|
Loading…
x
Reference in New Issue
Block a user