Skip to content

Commit

Permalink
[enh] add instant answers from ddg
Browse files Browse the repository at this point in the history
  • Loading branch information
allendema_searxng_pi authored and return42 committed May 24, 2024
1 parent 6c74bc8 commit 68365c8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions searx/engines/duckduckgo.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,19 @@ def response(resp):
len_tr_rows = len(tr_rows)
offset = 0

zero_click_info_xpath = '//html/body/form/div/table[2]/tr[2]/td/text()'
zero_click = extract_text(eval_xpath(doc, zero_click_info_xpath)).strip()

if zero_click:
current_query = resp.search_params["data"].get("q")

results.append(
{
'answer': zero_click,
'url': "https://duckduckgo.com/?" + urlencode({"q": current_query}),
}
)

while len_tr_rows >= offset + 4:

# assemble table rows we need to scrap
Expand Down

0 comments on commit 68365c8

Please sign in to comment.