on master help sign in
extract publishDate from vimeo
993271bThomas Pointhuber
searx/engines/vimeo.py+6
@@ -2,6 +2,8 @@ from urllib import urlencode
2from HTMLParser import HTMLParser
2from HTMLParser import HTMLParser
3from lxml import html
3from lxml import html
4from xpath import extract_text
4from xpath import extract_text
5+from datetime import datetime
6+from dateutil import parser
5
7
6base_url = 'http://vimeo.com'
8base_url = 'http://vimeo.com'
7search_url = base_url + '/search?{query}'
9search_url = base_url + '/search?{query}'
@@ -10,6 +12,7 @@ content_xpath = None
10title_xpath = None
12title_xpath = None
11results_xpath = ''
13results_xpath = ''
12content_tpl = '<a href="{0}"> <img src="{2}"/> </a>'
14content_tpl = '<a href="{0}"> <img src="{2}"/> </a>'
15+publishedDate_xpath = './/p[@class="meta"]//attribute::datetime'
13
16
14# the cookie set by vimeo contains all the following values,
17# the cookie set by vimeo contains all the following values,
15# but only __utma seems to be requiered
18# but only __utma seems to be requiered
@@ -40,9 +43,12 @@ def response(resp):
40 url = base_url + result.xpath(url_xpath)[0]
43 url = base_url + result.xpath(url_xpath)[0]
41 title = p.unescape(extract_text(result.xpath(title_xpath)))
44 title = p.unescape(extract_text(result.xpath(title_xpath)))
42 thumbnail = extract_text(result.xpath(content_xpath)[0])
45 thumbnail = extract_text(result.xpath(content_xpath)[0])
46+ publishedDate = parser.parse(extract_text(result.xpath(publishedDate_xpath)[0]))
47+
43 results.append({'url': url,
48 results.append({'url': url,
44 'title': title,
49 'title': title,
45 'content': content_tpl.format(url, title, thumbnail),
50 'content': content_tpl.format(url, title, thumbnail),
46 'template': 'videos.html',
51 'template': 'videos.html',
52+ 'publishedDate': publishedDate,
47 'thumbnail': thumbnail})
53 'thumbnail': thumbnail})
48 return results
54 return results
searx/engines/yahoo_news.py+1−1
@@ -53,7 +53,7 @@ def response(resp):
53 - timedelta(hours=int(timeNumbers[0]))\
53 - timedelta(hours=int(timeNumbers[0]))\
54 - timedelta(minutes=int(timeNumbers[1]))
54 - timedelta(minutes=int(timeNumbers[1]))
55 else:
55 else:
56− publishedDate =parser.parse(publishedDate)
56+ publishedDate = parser.parse(publishedDate)
57
57
58 if publishedDate.year == 1900:
58 if publishedDate.year == 1900:
59 publishedDate = publishedDate.replace(year=datetime.now().year)
59 publishedDate = publishedDate.replace(year=datetime.now().year)