mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Log results page title when no results found
This commit is contained in:
parent
e6b1cc0a49
commit
c7b753c469
@ -174,7 +174,7 @@ def bing_search(terms, site=None, br=None, log=prints, safe_search=False, dump_r
|
|||||||
try:
|
try:
|
||||||
div = li.xpath('descendant::div[@class="b_attribution" and @u]')[0]
|
div = li.xpath('descendant::div[@class="b_attribution" and @u]')[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
log('Ignoring', title, 'as it has no cached page')
|
log('Ignoring {!r} as it has no cached page'.format(title))
|
||||||
continue
|
continue
|
||||||
d, w = div.get('u').split('|')[-2:]
|
d, w = div.get('u').split('|')[-2:]
|
||||||
# The bing cache does not have a valid https certificate currently
|
# The bing cache does not have a valid https certificate currently
|
||||||
@ -182,6 +182,9 @@ def bing_search(terms, site=None, br=None, log=prints, safe_search=False, dump_r
|
|||||||
cached_url = 'http://cc.bingj.com/cache.aspx?q={q}&d={d}&mkt=en-US&setlang=en-US&w={w}'.format(
|
cached_url = 'http://cc.bingj.com/cache.aspx?q={q}&d={d}&mkt=en-US&setlang=en-US&w={w}'.format(
|
||||||
q=q, d=d, w=w)
|
q=q, d=d, w=w)
|
||||||
ans.append(Result(a.get('href'), title, cached_url))
|
ans.append(Result(a.get('href'), title, cached_url))
|
||||||
|
if not ans:
|
||||||
|
title = ' '.join(root.xpath('//title/text()'))
|
||||||
|
log('Failed to find any results on results page, with title:', title)
|
||||||
return ans, url
|
return ans, url
|
||||||
|
|
||||||
|
|
||||||
@ -226,10 +229,13 @@ def google_search(terms, site=None, br=None, log=prints, safe_search=False, dump
|
|||||||
try:
|
try:
|
||||||
c = div.xpath('descendant::div[@class="s"]//a[@class="fl"]')[0]
|
c = div.xpath('descendant::div[@class="s"]//a[@class="fl"]')[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
log('Ignoring', title, 'as it has no cached page')
|
log('Ignoring {!r} as it has no cached page'.format(title))
|
||||||
continue
|
continue
|
||||||
cached_url = c.get('href')
|
cached_url = c.get('href')
|
||||||
ans.append(Result(a.get('href'), title, cached_url))
|
ans.append(Result(a.get('href'), title, cached_url))
|
||||||
|
if not ans:
|
||||||
|
title = ' '.join(root.xpath('//title/text()'))
|
||||||
|
log('Failed to find any results on results page, with title:', title)
|
||||||
return ans, url
|
return ans, url
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user