Replace chompjs with pure Python code

The new implementation is good enough for the current usage (brave)
This commit is contained in:
Alexandre Flament 2023-09-09 10:18:39 +00:00
parent 8e45ac4271
commit d07c006aed
3 changed files with 75 additions and 3 deletions

View file

@ -104,7 +104,6 @@ from urllib.parse import (
parse_qs,
)
import chompjs
from lxml import html
from searx import locales
@ -112,6 +111,7 @@ from searx.utils import (
extract_text,
eval_xpath_list,
eval_xpath_getindex,
js_variable_to_python,
)
from searx.enginelib.traits import EngineTraits
@ -215,7 +215,7 @@ def response(resp):
datastr = line.replace("const data = ", "").strip()[:-1]
break
json_data = chompjs.parse_js_object(datastr)
json_data = js_variable_to_python(datastr)
json_resp = json_data[1]['data']['body']['response']
if brave_category == 'news':