[fix] duckduckgo: show proper source url of answers

This commit is contained in:
Bnyro 2025-03-17 20:51:13 +01:00 committed by Markus Heiser
parent 885d02c8c3
commit babbe9e1ae

View File

@ -8,7 +8,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import re import re
from urllib.parse import urlencode, quote_plus from urllib.parse import quote_plus
import json import json
import babel import babel
import lxml.html import lxml.html
@ -397,14 +397,10 @@ def response(resp) -> EngineResults:
and "Your user agent:" not in zero_click and "Your user agent:" not in zero_click
and "URL Decoded:" not in zero_click and "URL Decoded:" not in zero_click
): ):
current_query = resp.search_params["data"].get("q")
results.add( results.add(
results.types.Answer( results.types.Answer(
answer=zero_click, answer=zero_click,
url="https://duckduckgo.com/?" url=extract_text(eval_xpath(doc, '//div[@id="zero_click_abstract"]/a/@href')),
+ urlencode(
{"q": current_query},
),
) )
) )