summaryrefslogtreecommitdiff
path: root/searx/engines/google_news.py
diff options
context:
space:
mode:
authorThomas Pointhuber <thomas.pointhuber@gmx.at>2014-03-14 09:55:04 +0100
committerThomas Pointhuber <thomas.pointhuber@gmx.at>2014-03-14 09:55:11 +0100
commitb88146d669b1196ed1efc4ae4108e238cfd7dbca (patch)
treea960b54ea6673059bbbf9fc25addde39ea5a8859 /searx/engines/google_news.py
parenta559bad4884fa9dc60d44cd580812e1e2fedef80 (diff)
showing publishedDate for news
Diffstat (limited to 'searx/engines/google_news.py')
-rw-r--r--searx/engines/google_news.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/searx/engines/google_news.py b/searx/engines/google_news.py
index 935718609..afda3e756 100644
--- a/searx/engines/google_news.py
+++ b/searx/engines/google_news.py
@@ -2,6 +2,7 @@
from urllib import urlencode
from json import loads
+from datetime import datetime, timedelta
categories = ['news']
@@ -31,7 +32,15 @@ def response(resp):
return []
for result in search_res['responseData']['results']:
+# S.149 (159), library.pdf
+# datetime.strptime("Mon, 10 Mar 2014 16:26:15 -0700", "%a, %d %b %Y %H:%M:%S %z")
+# publishedDate = parse(result['publishedDate'])
+ publishedDate = datetime.strptime(str.join(' ',result['publishedDate'].split(None)[0:5]), "%a, %d %b %Y %H:%M:%S")
+ #utc_offset = timedelta(result['publishedDate'].split(None)[5]) # local = utc + offset
+ #publishedDate = publishedDate + utc_offset
+
results.append({'url': result['unescapedUrl'],
'title': result['titleNoFormatting'],
+ 'publishedDate': publishedDate,
'content': result['content']})
return results