Commit 1088c2a7 authored by Adam Tauber's avatar Adam Tauber

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

parent 801b5a56
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment