Fix for empty list error triggered by ASIN search

This commit is contained in:
Carson Gaspar 2018-02-20 20:05:31 -05:00
parent ef6fd9cf42
commit aa5420f470

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]