on master help sign in
extract publishDate from vimeo
commit993271bed30e24c7ae1e0f63b64e030829206f27 authorThomas Pointhuber <thomas.pointhuber@gmx.at> dateTue 18 Mar 2014, 15:56 (13 years ago) parent337bd6d
2 files changed+7−1
searx/engines/vimeo.py+6 searx/engines/yahoo_news.py+1−1
searx/engines/vimeo.py+6
@@ -2,6 +2,8 @@ from urllib import urlencode
22from HTMLParser import HTMLParser
33from lxml import html
44from xpath import extract_text
5+from datetime import datetime
6+from dateutil import parser
57
68base_url = 'http://vimeo.com'
79search_url = base_url + '/search?{query}'
@@ -10,6 +12,7 @@ content_xpath = None
1012title_xpath = None
1113results_xpath = ''
1214content_tpl = '<a href="{0}"> <img src="{2}"/> </a>'
15+publishedDate_xpath = './/p[@class="meta"]//attribute::datetime'
1316
1417# the cookie set by vimeo contains all the following values,
1518# but only __utma seems to be requiered
@@ -40,9 +43,12 @@ def response(resp):
4043 url = base_url + result.xpath(url_xpath)[0]
4144 title = p.unescape(extract_text(result.xpath(title_xpath)))
4245 thumbnail = extract_text(result.xpath(content_xpath)[0])
46+ publishedDate = parser.parse(extract_text(result.xpath(publishedDate_xpath)[0]))
47+
4348 results.append({'url': url,
4449 'title': title,
4550 'content': content_tpl.format(url, title, thumbnail),
4651 'template': 'videos.html',
52+ 'publishedDate': publishedDate,
4753 'thumbnail': thumbnail})
4854 return results
searx/engines/yahoo_news.py+1−1
@@ -53,7 +53,7 @@ def response(resp):
5353 - timedelta(hours=int(timeNumbers[0]))\
5454 - timedelta(minutes=int(timeNumbers[1]))
5555 else:
56− publishedDate =parser.parse(publishedDate)
56+ publishedDate = parser.parse(publishedDate)
5757
5858 if publishedDate.year == 1900:
5959 publishedDate = publishedDate.replace(year=datetime.now().year)