@@ -7,6 +7,7 @@ search_url = None
7url_xpath = None
7url_xpath = None
8content_xpath = None
8content_xpath = None
9title_xpath = None
9title_xpath = None
10+thumbnail_xpath = False
10paging = False
11paging = False
11suggestion_xpath = ''
12suggestion_xpath = ''
12results_xpath = ''
13results_xpath = ''
@@ -40,7 +41,9 @@ def extract_text(xpath_results):
40 return ''.join(xpath_results)
41 return ''.join(xpath_results)
42 # it's a element
43 # it's a element
44+ text = html.tostring(
43− text = html.tostring(xpath_results, encoding='unicode', method='text', with_tail=False)
45+ xpath_results, encoding='unicode', method='text', with_tail=False
44 text = text.strip().replace('\n', ' ')
47 text = text.strip().replace('\n', ' ')
45 return ' '.join(text.split())
48 return ' '.join(text.split())
@@ -105,7 +108,18 @@ def response(resp):
105 url = extract_url(result.xpath(url_xpath), search_url)
108 url = extract_url(result.xpath(url_xpath), search_url)
106 title = extract_text(result.xpath(title_xpath))
109 title = extract_text(result.xpath(title_xpath))
107 content = extract_text(result.xpath(content_xpath))
110 content = extract_text(result.xpath(content_xpath))
108− results.append({'url': url, 'title': title, 'content': content})
111+ tmp_result = {'url': url, 'title': title, 'content': content}
113+ # add thumbnail if available
116+ thumbnail = extract_url(
117+ result.xpath(thumbnail_xpath), search_url
120+ tmp_result['img_src'] = thumbnail
122+ results.append(tmp_result)
110 for url, title, content in zip(
124 for url, title, content in zip(
111 (extract_url(x, search_url) for
125 (extract_url(x, search_url) for