|
@@ -0,0 +1,65 @@
|
|
1
|
+# Ebay (Videos, Music, Files)
|
|
2
|
+#
|
|
3
|
+# @website https://www.ebay.com
|
|
4
|
+# @provide-api no (nothing found)
|
|
5
|
+#
|
|
6
|
+# @using-api no
|
|
7
|
+# @results HTML (using search portal)
|
|
8
|
+# @stable yes (HTML can change)
|
|
9
|
+# @parse url, title, content, price, shipping, source
|
|
10
|
+
|
|
11
|
+from lxml import html
|
|
12
|
+from searx.engines.xpath import extract_text
|
|
13
|
+from searx.url_utils import quote
|
|
14
|
+
|
|
15
|
+categories = ['shopping']
|
|
16
|
+paging = True
|
|
17
|
+
|
|
18
|
+url = 'https://www.ebay.com'
|
|
19
|
+search_url = url + '/sch/i.html?_nkw={query}&_pgn={pageno}'
|
|
20
|
+
|
|
21
|
+results_xpath = '//li[contains(@class, "lvresult")]'
|
|
22
|
+url_xpath = './h3[@class="lvtitle"]/a/@href'
|
|
23
|
+title_xpath = './h3[@class="lvtitle"]/a/text()'
|
|
24
|
+content_xpath = './div[@class="lvsubtitle"]/text()'
|
|
25
|
+price_xpath = './ul[@class="lvprices left space-zero"]/li[@class="lvprice prc"][1]/span[@class="bold"]'
|
|
26
|
+shipping_xpath = './ul[@class="lvprices left space-zero"]/li[@class="lvshipping"]/span[@class="ship"]/span/span/text()'
|
|
27
|
+source_country_xpath = './ul[contains(@class, "lvdetails")]/li[1]'
|
|
28
|
+thumbnail_xpath = './div[contains(@class, "lvpic")]//img/@src'
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+def request(query, params):
|
|
32
|
+ params['url'] = search_url.format(query=quote(query), pageno=params['pageno'])
|
|
33
|
+ return params
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+def response(resp):
|
|
37
|
+ results = []
|
|
38
|
+
|
|
39
|
+ dom = html.fromstring(resp.text)
|
|
40
|
+ results_dom = dom.xpath(results_xpath)
|
|
41
|
+ if not results_dom:
|
|
42
|
+ return []
|
|
43
|
+
|
|
44
|
+ for result_dom in results_dom:
|
|
45
|
+ url = extract_text(result_dom.xpath(url_xpath))
|
|
46
|
+ title = extract_text(result_dom.xpath(title_xpath))
|
|
47
|
+ content = extract_text(result_dom.xpath(content_xpath))
|
|
48
|
+ price = extract_text(result_dom.xpath(price_xpath))
|
|
49
|
+ shipping = extract_text(result_dom.xpath(shipping_xpath))
|
|
50
|
+ source_country = extract_text(result_dom.xpath(source_country_xpath))
|
|
51
|
+ thumbnail = extract_text(result_dom.xpath(thumbnail_xpath))
|
|
52
|
+
|
|
53
|
+ results.append({
|
|
54
|
+ 'url': url,
|
|
55
|
+ 'title': title,
|
|
56
|
+ 'content': content,
|
|
57
|
+ 'price': price,
|
|
58
|
+ 'shipping': shipping,
|
|
59
|
+ 'source_country': source_country,
|
|
60
|
+ 'thumbnail': thumbnail,
|
|
61
|
+ 'template': 'products.html',
|
|
62
|
+
|
|
63
|
+ })
|
|
64
|
+
|
|
65
|
+ return results
|