Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Sep 7, 2023. It is now read-only.

Conversation

@allendema
Copy link
Contributor

Raw response example: https://search.brave.com/api/suggest?q=how%20to:%20with%20j

Headers are needed in order to get a 200 response, thus Searx user-agent is used.

Other URL param could be '&rich=false' or '&rich=true'.

What does this PR do?

Add autocompleter from Brave.

Imports searx_useragent.

Why is this change important?

More options to choose from.

How to test this PR locally?

Type something in te search box.

Author's checklist

N/A

Related issues

N/A

Raw response example: https://search.brave.com/api/suggest?q=how%20to:%20with%20j

Headers are needed in order to get a 200 response, thus Searx user-agent is used.

Other URL param could be  '&rich=false' or  '&rich=true'.
@kvch
Copy link
Member

kvch commented Jan 7, 2022

I might be doing something wrong. When I am typing in the search area, I get no suggestions.
This is the backtrace I get:

INFO:werkzeug:127.0.0.1 - - [07/Jan/2022 21:45:27] "GET /autocompleter?q=hall HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/n/p/searx/venv3.9/lib/python3.9/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/n/p/searx/searx/webapp.py", line 1207, in __call__
    return self.app(environ, start_response)
  File "/home/n/p/searx/venv3.9/lib/python3.9/site-packages/werkzeug/middleware/proxy_fix.py", line 169, in __ca
ll__
    return self.app(environ, start_response)
  File "/home/n/p/searx/venv3.9/lib/python3.9/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/home/n/p/searx/venv3.9/lib/python3.9/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/n/p/searx/venv3.9/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/n/p/searx/venv3.9/lib/python3.9/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/n/p/searx/venv3.9/lib/python3.9/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/n/p/searx/venv3.9/lib/python3.9/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/n/p/searx/venv3.9/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/n/p/searx/venv3.9/lib/python3.9/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/n/p/searx/venv3.9/lib/python3.9/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/n/p/searx/searx/webapp.py", line 813, in autocompleter
    raw_results = search_autocomplete(
  File "/home/n/p/searx/searx/autocomplete.py", line 161, in search_autocomplete
    return backend(query, lang)
  File "/home/n/p/searx/searx/autocomplete.py", line 45, in brave
    params['headers']['User-Agent'] = searx_useragent()
TypeError: string indices must be integers

Apparently no header modification is needed. So removed previously imported searx_useragent().

Change var name from item to suggestion.
Again.
Co-authored-by: Noémi Ványi <[email protected]>
@allendema
Copy link
Contributor Author

Woah, thanks, missed it again.

Copy link
Member

@kvch kvch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the new autocompleter!

@kvch kvch merged commit 321ddc9 into searx:master Jan 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants