1
0
mirror of https://github.com/searx/searx synced 2024-12-13 20:50:55 +01:00

[fix] do not crash if publication date is missing in pubmed engine

This commit is contained in:
Adam Tauber 2017-12-01 20:48:10 +01:00
parent 801b5a56ad
commit 1088c2a75d

View File

@ -84,15 +84,18 @@ def response(resp):
content = content[0:300] + "..."
# TODO: center snippet on query term
publishedDate = datetime.strptime(entry.xpath('.//DateCreated/Year')[0].text
+ '-' + entry.xpath('.//DateCreated/Month')[0].text
+ '-' + entry.xpath('.//DateCreated/Day')[0].text, '%Y-%m-%d')
res_dict = {'url': url,
'title': title,
'publishedDate': publishedDate,
'content': content}
try:
publishedDate = datetime.strptime(entry.xpath('.//DateCreated/Year')[0].text
+ '-' + entry.xpath('.//DateCreated/Month')[0].text
+ '-' + entry.xpath('.//DateCreated/Day')[0].text, '%Y-%m-%d')
res_dict['publishedDate'] = publishedDate
except:
pass
results.append(res_dict)
return results