@@ -4,6 +4,7 @@ from urllib import urlencode
4from lxml import html
4from lxml import html
5from searx.engines.xpath import extract_text, extract_url
5from searx.engines.xpath import extract_text, extract_url
6from searx.engines.yahoo import parse_url
6from searx.engines.yahoo import parse_url
7+from datetime import datetime
8categories = ['news']
9categories = ['news']
9search_url = 'http://news.search.yahoo.com/search?{query}&b={offset}'
10search_url = 'http://news.search.yahoo.com/search?{query}&b={offset}'
@@ -11,6 +12,7 @@ results_xpath = '//div[@class="res"]'
11url_xpath = './/h3/a/@href'
12url_xpath = './/h3/a/@href'
12title_xpath = './/h3/a'
13title_xpath = './/h3/a'
13content_xpath = './/div[@class="abstr"]'
14content_xpath = './/div[@class="abstr"]'
15+publishedDate_xpath = './/span[@class="timestamp"]'
14suggestion_xpath = '//div[@id="satat"]//a'
16suggestion_xpath = '//div[@id="satat"]//a'
16paging = True
18paging = True
@@ -37,7 +39,10 @@ def response(resp):
37 url = parse_url(extract_url(result.xpath(url_xpath), search_url))
39 url = parse_url(extract_url(result.xpath(url_xpath), search_url))
38 title = extract_text(result.xpath(title_xpath)[0])
40 title = extract_text(result.xpath(title_xpath)[0])
39 content = extract_text(result.xpath(content_xpath)[0])
41 content = extract_text(result.xpath(content_xpath)[0])
43+ publishedDate = datetime.strptime(extract_text(result.xpath(publishedDate_xpath)[0]),"%b %d %H:%M%p")
44+ #publishedDate.replace(year=2014)
40− results.append({'url': url, 'title': title, 'content': content})
45+ results.append({'url': url, 'title': title, 'content': content,'publishedDate':publishedDate})
42 if not suggestion_xpath:
47 if not suggestion_xpath:
43 return results
48 return results