diff options
author | Adam Tauber <asciimoo@gmail.com> | 2017-12-01 20:48:10 +0100 |
---|---|---|
committer | Adam Tauber <asciimoo@gmail.com> | 2017-12-01 20:54:12 +0100 |
commit | 1088c2a75dbfd4d5fba418fd2ceb1a7fd375fda1 (patch) | |
tree | c4bc39d9f233f994869763733b2d9bbf9884b793 /searx/engines/pubmed.py | |
parent | 801b5a56ad93065b4a5e69652cf97aadc874ef57 (diff) | |
download | searxng-1088c2a75dbfd4d5fba418fd2ceb1a7fd375fda1.tar.gz searxng-1088c2a75dbfd4d5fba418fd2ceb1a7fd375fda1.zip |
[fix] do not crash if publication date is missing in pubmed engine
Diffstat (limited to 'searx/engines/pubmed.py')
-rw-r--r-- | searx/engines/pubmed.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/searx/engines/pubmed.py b/searx/engines/pubmed.py index 6451f1467..055f09226 100644 --- a/searx/engines/pubmed.py +++ b/searx/engines/pubmed.py @@ -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 |