forked from zaclys/searxng
[fix] do not crash if publication date is missing in pubmed engine
This commit is contained in:
parent
801b5a56ad
commit
1088c2a75d
|
@ -84,14 +84,17 @@ def response(resp):
|
||||||
content = content[0:300] + "..."
|
content = content[0:300] + "..."
|
||||||
# TODO: center snippet on query term
|
# TODO: center snippet on query term
|
||||||
|
|
||||||
|
res_dict = {'url': url,
|
||||||
|
'title': title,
|
||||||
|
'content': content}
|
||||||
|
|
||||||
|
try:
|
||||||
publishedDate = datetime.strptime(entry.xpath('.//DateCreated/Year')[0].text
|
publishedDate = datetime.strptime(entry.xpath('.//DateCreated/Year')[0].text
|
||||||
+ '-' + entry.xpath('.//DateCreated/Month')[0].text
|
+ '-' + entry.xpath('.//DateCreated/Month')[0].text
|
||||||
+ '-' + entry.xpath('.//DateCreated/Day')[0].text, '%Y-%m-%d')
|
+ '-' + entry.xpath('.//DateCreated/Day')[0].text, '%Y-%m-%d')
|
||||||
|
res_dict['publishedDate'] = publishedDate
|
||||||
res_dict = {'url': url,
|
except:
|
||||||
'title': title,
|
pass
|
||||||
'publishedDate': publishedDate,
|
|
||||||
'content': content}
|
|
||||||
|
|
||||||
results.append(res_dict)
|
results.append(res_dict)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue