From 4f90fb6a9236a9699e80c249153ba372bf308cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sp=C3=BChler=20Stefan?= Date: Mon, 2 Mar 2020 18:55:48 +0100 Subject: [PATCH 1/2] [Fix] Startpage ValueError on Spanish date format datetime.parser.parse() does not know the Spanish date format which leads to a ValueError. Fixes #1870 Traceback (most recent call last): File "/usr/local/searx/searx/search.py", line 160, in search_one_http_request_safe search_results = search_one_http_request(engine, query, request_params) File "/usr/local/searx/searx/search.py", line 97, in search_one_http_request return engine.response(response) File "/usr/local/searx/searx/engines/startpage.py", line 102, in response published_date = parser.parse(date_string, dayfirst=True) File "/usr/local/searx/searx-ve/lib/python3.6/site-packages/dateutil/parser/_parser.py", line 1358, in parse return DEFAULTPARSER.parse(timestr, **kwargs) File "/usr/local/searx/searx-ve/lib/python3.6/site-packages/dateutil/parser/_parser.py", line 649, in parse raise ValueError("Unknown string format:", timestr) ValueError: ('Unknown string format:', '24 Ene 2013') --- searx/engines/startpage.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/searx/engines/startpage.py b/searx/engines/startpage.py index 76567396f..953734934 100644 --- a/searx/engines/startpage.py +++ b/searx/engines/startpage.py @@ -99,11 +99,14 @@ def response(resp): if re.match(r"^([1-9]|[1-2][0-9]|3[0-1]) [A-Z][a-z]{2} [0-9]{4} \.\.\. ", content): date_pos = content.find('...') + 4 date_string = content[0:date_pos - 5] - published_date = parser.parse(date_string, dayfirst=True) - # fix content string content = content[date_pos:] + try: + published_date = parser.parse(date_string, dayfirst=True) + except ValueError: + pass + # check if search result starts with something like: "5 days ago ... " elif re.match(r"^[0-9]+ days? ago \.\.\. ", content): date_pos = content.find('...') + 4 From 3973951770146f35d52664e971b76026af15d9f9 Mon Sep 17 00:00:00 2001 From: Dalf Date: Wed, 8 Apr 2020 15:58:26 +0200 Subject: [PATCH 2/2] [mod] requirements.txt: upgrade dependency versions. --- requirements.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/requirements.txt b/requirements.txt index ea4a5a7a0..5d508d7ee 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,12 @@ -certifi==2019.3.9 +certifi==2020.4.5.1 babel==2.7.0 flask-babel==1.0.0 -flask==1.0.2 -idna==2.8 -jinja2==2.10.1 -lxml==4.3.3 +flask==1.1.2 +idna==2.9 +jinja2==2.11.1 +lxml==4.5.0 pygments==2.1.3 -pyopenssl==19.0.0 +pyopenssl==19.1.0 python-dateutil==2.8.0 -pyyaml==5.1 -requests[socks]==2.22.0 +pyyaml==5.3.1 +requests[socks]==2.23.0