44def response(resp):
45 results = []
46
47 dom = html.fromstring(resp.text)
48 results_dom = dom.xpath(results_xpath)
49 if not results_dom:
50 return []
51
52 for result_dom in results_dom:
53 url = extract_text(result_dom.xpath(url_xpath))
54 title = extract_text(result_dom.xpath(title_xpath))
55 content = extract_text(result_dom.xpath(content_xpath))
56 price = extract_text(result_dom.xpath(price_xpath))
57 shipping = extract_text(result_dom.xpath(shipping_xpath))
58 source_country = extract_text(result_dom.xpath(source_country_xpath))
59 thumbnail = extract_text(result_dom.xpath(thumbnail_xpath))
60
61 if title == "":
62 continue
63
64 results.append(
65 {
66 'url': url,
67 'title': title,
68 'content': content,
69 'price': price,
70 'shipping': shipping,
71 'source_country': source_country,
72 'thumbnail': thumbnail,
73 'template': 'products.html',
74 }
75 )
76
77 return results