@@ -75,15 +75,17 @@ def response(resp):
7575
7676 # get thumbnails
7777 script = str(dom.xpath('//script[contains(., "_setImagesSrc")]')[0].text)
78− id = result.xpath('.//div[@class="s"]//img/@id')[0]
79− thumbnails_data = re.findall('s=\'(.*?)(?:\\\\[a-z,1-9,\\\\]+\'|\')\;var ii=\[(?:|[\'vidthumb\d+\',]+)\'' + id,
80− script)
81− tmp = []
82− if len(thumbnails_data) != 0:
83− tmp = re.findall('(data:image/jpeg;base64,[a-z,A-Z,0-9,/,\+]+)', thumbnails_data[0])
84− thumbnail = ''
85− if len(tmp) != 0:
86− thumbnail = tmp[-1]
78+ ids = result.xpath('.//div[@class="s"]//img/@id')
79+ if len(ids) > 0:
80+ thumbnails_data = \
81+ re.findall('s=\'(.*?)(?:\\\\[a-z,1-9,\\\\]+\'|\')\;var ii=\[(?:|[\'vidthumb\d+\',]+)\'' + ids[0],
82+ script)
83+ tmp = []
84+ if len(thumbnails_data) != 0:
85+ tmp = re.findall('(data:image/jpeg;base64,[a-z,A-Z,0-9,/,\+]+)', thumbnails_data[0])
86+ thumbnail = ''
87+ if len(tmp) != 0:
88+ thumbnail = tmp[-1]
8789
8890 # append result
8991 results.append({'url': url,