summaryrefslogtreecommitdiff
path: root/searx/engines/brave.py
diff options
context:
space:
mode:
authorAllen <64094914+allendema@users.noreply.github.com>2024-05-23 23:21:58 +0000
committerMarkus Heiser <markus.heiser@darmarIT.de>2024-05-29 17:56:17 +0200
commit0fa81fc782feb104bbd6616d87a6f441aad7d5bd (patch)
tree4fd2f697240307d616f8b49614787852e5923fc4 /searx/engines/brave.py
parent0fb3f0e4aeecf62612cb6568910cf0f97c98cab9 (diff)
downloadsearxng-0fa81fc782feb104bbd6616d87a6f441aad7d5bd.tar.gz
searxng-0fa81fc782feb104bbd6616d87a6f441aad7d5bd.zip
[enh] add re-usable func to filter text
Diffstat (limited to 'searx/engines/brave.py')
-rw-r--r--searx/engines/brave.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/searx/engines/brave.py b/searx/engines/brave.py
index 04c2931f9..c5780a02c 100644
--- a/searx/engines/brave.py
+++ b/searx/engines/brave.py
@@ -132,6 +132,7 @@ from lxml import html
from searx import locales
from searx.utils import (
extract_text,
+ extr,
eval_xpath,
eval_xpath_list,
eval_xpath_getindex,
@@ -252,11 +253,7 @@ def response(resp):
if brave_category in ('search', 'goggles'):
return _parse_search(resp)
- datastr = ""
- for line in resp.text.split("\n"):
- if "const data = " in line:
- datastr = line.replace("const data = ", "").strip()[:-1]
- break
+ datastr = extr(resp.text, "const data = ", ";\n").strip()
json_data = js_variable_to_python(datastr)
json_resp = json_data[1]['data']['body']['response']