summaryrefslogtreecommitdiff
path: root/searx/engines/vimeo.py
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2014-03-18 18:20:10 +0100
committerAdam Tauber <asciimoo@gmail.com>2014-03-18 18:20:10 +0100
commit018a14431bd3612db4e8840ce24f3e60026ece0f (patch)
tree18c7f0ed489c0c0f206ac1f0a191b1ce0ab045b2 /searx/engines/vimeo.py
parentfaed14b2c691746ba6cf98d164a5e6b1ca3ee4c9 (diff)
parent993271bed30e24c7ae1e0f63b64e030829206f27 (diff)
Merge pull request #57 from pointhi/results
improving publishDate extraction and output of it
Diffstat (limited to 'searx/engines/vimeo.py')
-rw-r--r--searx/engines/vimeo.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/searx/engines/vimeo.py b/searx/engines/vimeo.py
index a95c75b49..d2d2a4dd0 100644
--- a/searx/engines/vimeo.py
+++ b/searx/engines/vimeo.py
@@ -2,6 +2,8 @@ from urllib import urlencode
from HTMLParser import HTMLParser
from lxml import html
from xpath import extract_text
+from datetime import datetime
+from dateutil import parser
base_url = 'http://vimeo.com'
search_url = base_url + '/search?{query}'
@@ -10,6 +12,7 @@ content_xpath = None
title_xpath = None
results_xpath = ''
content_tpl = '<a href="{0}"> <img src="{2}"/> </a>'
+publishedDate_xpath = './/p[@class="meta"]//attribute::datetime'
# the cookie set by vimeo contains all the following values,
# but only __utma seems to be requiered
@@ -40,9 +43,12 @@ def response(resp):
url = base_url + result.xpath(url_xpath)[0]
title = p.unescape(extract_text(result.xpath(title_xpath)))
thumbnail = extract_text(result.xpath(content_xpath)[0])
+ publishedDate = parser.parse(extract_text(result.xpath(publishedDate_xpath)[0]))
+
results.append({'url': url,
'title': title,
'content': content_tpl.format(url, title, thumbnail),
'template': 'videos.html',
+ 'publishedDate': publishedDate,
'thumbnail': thumbnail})
return results