From a9dadda6f7bcc7785114afff9fe646b890d6ed56 Mon Sep 17 00:00:00 2001 From: br4nnigan <10244835+br4nnigan@users.noreply.github.com> Date: Wed, 28 Sep 2022 20:49:51 +0200 Subject: [PATCH] allow engines to override pretty_url and use this in bing to show meaningful urls --- searx/engines/bing.py | 2 ++ searx/webapp.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/searx/engines/bing.py b/searx/engines/bing.py index 61abd466..7d9d8549 100644 --- a/searx/engines/bing.py +++ b/searx/engines/bing.py @@ -68,11 +68,13 @@ def response(resp): for result in eval_xpath(dom, '//div[@class="sa_cc"]'): link = eval_xpath(result, './/h3/a')[0] url = link.attrib.get('href') + pretty_url = extract_text(eval_xpath(result, './/cite')) title = extract_text(link) content = extract_text(eval_xpath(result, './/p')) # append result results.append({'url': url, + 'pretty_url': pretty_url, 'title': title, 'content': content}) diff --git a/searx/webapp.py b/searx/webapp.py index e37eaf73..9f5a004b 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -647,7 +647,7 @@ def search(): # removing html content and whitespace duplications result['title'] = ' '.join(html_to_text(result['title']).strip().split()) - if 'url' in result: + if 'url' in result and !('pretty_url' in result): result['pretty_url'] = prettify_url(result['url']) # TODO, check if timezone is calculated right