|
@@ -13,24 +13,23 @@
|
13
|
13
|
# @todo set content-parameter with correct data
|
14
|
14
|
|
15
|
15
|
from urllib import urlencode
|
16
|
|
-from HTMLParser import HTMLParser
|
17
|
16
|
from lxml import html
|
18
|
|
-from searx.engines.xpath import extract_text
|
19
|
17
|
from dateutil import parser
|
|
18
|
+from cgi import escape
|
20
|
19
|
|
21
|
20
|
# engine dependent config
|
22
|
21
|
categories = ['videos']
|
23
|
22
|
paging = True
|
24
|
23
|
|
25
|
24
|
# search-url
|
26
|
|
-base_url = 'https://vimeo.com'
|
|
25
|
+base_url = 'http://vimeo.com'
|
27
|
26
|
search_url = base_url + '/search/page:{pageno}?{query}'
|
28
|
27
|
|
29
|
28
|
# specific xpath variables
|
|
29
|
+results_xpath = '//div[@id="browse_content"]/ol/li'
|
30
|
30
|
url_xpath = './a/@href'
|
|
31
|
+title_xpath = './a/div[@class="data"]/p[@class="title"]'
|
31
|
32
|
content_xpath = './a/img/@src'
|
32
|
|
-title_xpath = './a/div[@class="data"]/p[@class="title"]/text()'
|
33
|
|
-results_xpath = '//div[@id="browse_content"]/ol/li'
|
34
|
33
|
publishedDate_xpath = './/p[@class="meta"]//attribute::datetime'
|
35
|
34
|
|
36
|
35
|
|
|
@@ -39,10 +38,6 @@ def request(query, params):
|
39
|
38
|
params['url'] = search_url.format(pageno=params['pageno'],
|
40
|
39
|
query=urlencode({'q': query}))
|
41
|
40
|
|
42
|
|
- # TODO required?
|
43
|
|
- params['cookies']['__utma'] =\
|
44
|
|
- '00000000.000#0000000.0000000000.0000000000.0000000000.0'
|
45
|
|
-
|
46
|
41
|
return params
|
47
|
42
|
|
48
|
43
|
|
|
@@ -52,15 +47,12 @@ def response(resp):
|
52
|
47
|
|
53
|
48
|
dom = html.fromstring(resp.text)
|
54
|
49
|
|
55
|
|
- p = HTMLParser()
|
56
|
|
-
|
57
|
50
|
# parse results
|
58
|
51
|
for result in dom.xpath(results_xpath):
|
59
|
52
|
url = base_url + result.xpath(url_xpath)[0]
|
60
|
|
- title = p.unescape(extract_text(result.xpath(title_xpath)))
|
61
|
|
- thumbnail = extract_text(result.xpath(content_xpath)[0])
|
62
|
|
- publishedDate = parser.parse(extract_text(
|
63
|
|
- result.xpath(publishedDate_xpath)[0]))
|
|
53
|
+ title = escape(html.tostring(result.xpath(title_xpath)[0], method='text', encoding='UTF-8').decode("utf-8"))
|
|
54
|
+ thumbnail = result.xpath(content_xpath)[0]
|
|
55
|
+ publishedDate = parser.parse(result.xpath(publishedDate_xpath)[0])
|
64
|
56
|
|
65
|
57
|
# append result
|
66
|
58
|
results.append({'url': url,
|