on master help sign in
Merge pull request #1879 from bauruine/fix_startpage_ValueError_on_spanish_datetime

[Fix] Startpage ValueError on Spanish date format

commit826ef3d00959f22a57224fa5e69fb088583f0072 authorNoémi Ványi <kvch@users.noreply.github.com> dateWed 15 Apr 2020, 23:41 (7 years ago) parent4eddbcafcb44c6
1 file changed+5−2
searx/engines/startpage.py+5−2
searx/engines/startpage.py+5−2
@@ -99,11 +99,14 @@ def response(resp):
9999 if re.match(r"^([1-9]|[1-2][0-9]|3[0-1]) [A-Z][a-z]{2} [0-9]{4} \.\.\. ", content):
100100 date_pos = content.find('...') + 4
101101 date_string = content[0:date_pos - 5]
102− published_date = parser.parse(date_string, dayfirst=True)
103−
104102 # fix content string
105103 content = content[date_pos:]
106104
105+ try:
106+ published_date = parser.parse(date_string, dayfirst=True)
107+ except ValueError:
108+ pass
109+
107110 # check if search result starts with something like: "5 days ago ... "
108111 elif re.match(r"^[0-9]+ days? ago \.\.\. ", content):
109112 date_pos = content.find('...') + 4