summaryrefslogtreecommitdiff
path: root/searx/engines/brave.py
AgeCommit message (Collapse)Author
2025-12-17[fix] engine: brave - BrotliDecoderDecompressStream encoding issue (#5572)Guanzhong Chen
For some reason, I keep getting this error from the brave engine: httpx.DecodingError: BrotliDecoderDecompressStream failed while processing the stream Forcing the server to use either gzip or deflate fixes this issue. This makes the brave engine work when the server seems to be encoding brotli incorrectly, or at least in a way incompatible with certain installs. Related: - https://github.com/searxng/searxng/pull/1787 - https://github.com/searxng/searxng/pull/5536
2025-12-01[fix] brave: content description also contains website URL (#5502)Bnyro
there are other classes like 'site-name-content' we don't want to match, however only using contains(@class, 'content') would e.g. also match `site-name-content` thus, we explicitly also require the spaces as class separator
2025-11-25[fix] brave engines - web, images & videos (#5478)Markus Heiser
brave web: xpath selectors needed to be justified brave images & videos: The JS code with the JS object was read incorrectly; not always, but quite often, it led to exceptions when the Python data structure was created from it. BTW: A complete review was conducted and corrections or additions were made to the type definitions. To test all brave engines in once:: !br !brimg !brvid !brnews weather Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-11-25[mod] replace js_variable_to_python by js_obj_str_to_python (#2792) (#5477)Markus Heiser
This patch is based on PR #2792 (old PR from 2023) - js_obj_str_to_python handle more cases - bring tests from chompjs .. - comment out tests do not pass The tests from chompjs give some overview of what is not implemented. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-11-06[enh] py: drop deps (#5407)Ivan Gabaldon
The difference between decompression with brotli or gzip in HTML files is negligible for 3 MB of compiled binary package. Introduced in https://github.com/searxng/searxng/commit/eaa694fb7d0e47b943bc6d6edb6cb6a40ab2d85e Closes https://github.com/searxng/searxng/security/code-scanning/276 Closes https://github.com/searxng/searxng/security/dependabot/37
2025-09-03[mod] addition of various type hints / tbcMarkus Heiser
- pyright configuration [1]_ - stub files: types-lxml [2]_ - addition of various type hints - enable use of new type system features on older Python versions [3]_ - ``.tool-versions`` - set python to lowest version we support (3.10.18) [4]_: Older versions typically lack some typing features found in newer Python versions. Therefore, for local type checking (before commit), it is necessary to use the older Python interpreter. .. [1] https://docs.basedpyright.com/v1.20.0/configuration/config-files/ .. [2] https://pypi.org/project/types-lxml/ .. [3] https://typing-extensions.readthedocs.io/en/latest/# .. [4] https://mise.jdx.dev/configuration.html#tool-versions Signed-off-by: Markus Heiser <markus.heiser@darmarit.de> Format: reST
2025-04-30[fix] brave: fix images and videos enginesBnyro
2025-03-02[fix] brave engine: add sec-fetch headers and source=web argumentMarkus Heiser
The intention is to reduce the "TooManyRequestsException". Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-02-20[fix] engines bing.images & brave.videos - fix parse data stringMarkus Heiser
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-02-20[fix] brave.news engine: response is HTML and no longer JSONMarkus Heiser
The response from brave.com for news is no longer a JSON string. Closes: https://github.com/searxng/searxng/issues/4352 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-01-28[refactor] typification of SearXNG / EngineResultsMarkus Heiser
In [1] and [2] we discussed the need of a Result.results property and how we can avoid unclear code. This patch implements a class for the reslut-lists of engines:: searx.result_types.EngineResults A simple example for the usage in engine development:: from searx.result_types import EngineResults ... def response(resp) -> EngineResults: res = EngineResults() ... res.add( res.types.Answer(answer="lorem ipsum ..", url="https://example.org") ) ... return res [1] https://github.com/searxng/searxng/pull/4183#pullrequestreview-257400034 [2] https://github.com/searxng/searxng/pull/4183#issuecomment-2614301580 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-01-28[refactor] typification of SearXNG (initial) / result items (part 1)Markus Heiser
Typification of SearXNG ======================= This patch introduces the typing of the results. The why and how is described in the documentation, please generate the documentation .. $ make docs.clean docs.live and read the following articles in the "Developer documentation": - result types --> http://0.0.0.0:8000/dev/result_types/index.html The result types are available from the `searx.result_types` module. The following have been implemented so far: - base result type: `searx.result_type.Result` --> http://0.0.0.0:8000/dev/result_types/base_result.html - answer results --> http://0.0.0.0:8000/dev/result_types/answer.html including the type for translations (inspired by #3925). For all other types (which still need to be set up in subsequent PRs), template documentation has been created for the transition period. Doc of the fields used in Templates =================================== The template documentation is the basis for the typing and is the first complete documentation of the results (needed for engine development). It is the "working paper" (the plan) with which further typifications can be implemented in subsequent PRs. - https://github.com/searxng/searxng/issues/357 Answer Templates ================ With the new (sub) types for `Answer`, the templates for the answers have also been revised, `Translation` are now displayed with collapsible entries (inspired by #3925). !en-de dog Plugins & Answerer ================== The implementation for `Plugin` and `Answer` has been revised, see documentation: - Plugin: http://0.0.0.0:8000/dev/plugins/index.html - Answerer: http://0.0.0.0:8000/dev/answerers/index.html With `AnswerStorage` and `AnswerStorage` to manage those items (in follow up PRs, `ArticleStorage`, `InfoStorage` and .. will be implemented) Autocomplete ============ The autocompletion had a bug where the results from `Answer` had not been shown in the past. To test activate autocompletion and try search terms for which we have answerers - statistics: type `min 1 2 3` .. in the completion list you should find an entry like `[de] min(1, 2, 3) = 1` - random: type `random uuid` .. in the completion list, the first item is a random UUID Extended Types ============== SearXNG extends e.g. the request and response types of flask and httpx, a module has been set up for type extensions: - Extended Types --> http://0.0.0.0:8000/dev/extended_types.html Unit-Tests ========== The unit tests have been completely revised. In the previous implementation, the runtime (the global variables such as `searx.settings`) was not initialized before each test, so the runtime environment with which a test ran was always determined by the tests that ran before it. This was also the reason why we sometimes had to observe non-deterministic errors in the tests in the past: - https://github.com/searxng/searxng/issues/2988 is one example for the Runtime issues, with non-deterministic behavior .. - https://github.com/searxng/searxng/pull/3650 - https://github.com/searxng/searxng/pull/3654 - https://github.com/searxng/searxng/pull/3642#issuecomment-2226884469 - https://github.com/searxng/searxng/pull/3746#issuecomment-2300965005 Why msgspec.Struct ================== We have already discussed typing based on e.g. `TypeDict` or `dataclass` in the past: - https://github.com/searxng/searxng/pull/1562/files - https://gist.github.com/dalf/972eb05e7a9bee161487132a7de244d2 - https://github.com/searxng/searxng/pull/1412/files - https://github.com/searxng/searxng/pull/1356 In my opinion, TypeDict is unsuitable because the objects are still dictionaries and not instances of classes / the `dataclass` are classes but ... The `msgspec.Struct` combine the advantages of typing, runtime behaviour and also offer the option of (fast) serializing (incl. type check) the objects. Currently not possible but conceivable with `msgspec`: Outsourcing the engines into separate processes, what possibilities this opens up in the future is left to the imagination! Internally, we have already defined that it is desirable to decouple the development of the engines from the development of the SearXNG core / The serialization of the `Result` objects is a prerequisite for this. HINT: The threads listed above were the template for this PR, even though the implementation here is based on msgspec. They should also be an inspiration for the following PRs of typification, as the models and implementations can provide a good direction. Why just one commit? ==================== I tried to create several (thematically separated) commits, but gave up at some point ... there are too many things to tackle at once / The comprehensibility of the commits would not be improved by a thematic separation. On the contrary, we would have to make multiple changes at the same places and the goal of a change would be vaguely recognizable in the fog of the commits. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-01-20[fix] engine brave: remove date from the content stringMarkus Heiser
Related: https://github.com/searxng/searxng/issues/4211#issuecomment-2601941440 Closes: https://github.com/searxng/searxng/issues/4006 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-10-03add get_embeded_stream_url to searx.utilsAustin-Olacsi
2024-09-15[fix] fetch_traits: brave, google, annas_archive & radio_browserMarkus
This patch fixes a bug reported by CI "Fetch traits" [1] (brave) and improves other fetch traits functions (google, annas_archive & radio_browser). brave: File "/home/runner/work/searxng/searxng/searx/engines/brave.py", line 434, in fetch_traits sxng_tag = region_tag(babel.Locale.parse(ui_lang, sep='-')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/runner/work/searxng/searxng/searx/locales.py", line 155, in region_tag Error: raise ValueError('%s missed a territory') google: change ERROR message about unknow UI language to INFO message radio_browser: country_list contains duplicates that differ only in upper/lower case annas_archive: for better diff; sort the persistence of the traits [1] https://github.com/searxng/searxng/actions/runs/10606312371/job/29433352518#step:6:41 Signed-off-by: Markus <markus@venom.fritz.box>
2024-07-29[fix] brave fetch_traits: Brave added Chinese (zh-hant) to UIMarkus Heiser
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-06-25[fix] brave fetch_traits: layout of the settings page has changedMarkus Heiser
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-05-29[enh] add re-usable func to filter textAllen
2024-05-16[mod] simple theme: drop img_src from default resultsMarkus Heiser
The use of img_src AND thumbnail in the default results makes no sense (only a thumbnail is needed). In the current state this is rather confusing, because img_src is displayed like a thumbnail (small) and thumbnail is displayed like an image (large). Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-03-11[mod] pylint all engines without PYLINT_SEARXNG_DISABLE_OPTIONMarkus Heiser
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-02-25[refactor] images: add resolution, image format and filesize fieldsBnyro
Co-authored-by: Markus Heiser <markus.heiser@darmarit.de>
2024-02-10[feat] engine: implementation of brave gogglesHackurei
2024-01-31[fix] brave.search - update result selectors to fit to new layoutMarkus Heiser
Closes: https://github.com/searxng/searxng/issues/3167 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-01-30[feat] brave: fix empty content and parse published datesBnyro
2023-12-03[mod] add option max_page to bing, brave, qwant, startpage & mojeekMarkus Heiser
[1] https://github.com/searxng/searxng/issues/2982#issuecomment-1808975780 Reported-by: @Damaj301damaj-lol [1] Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-10-13fixing results parsing braveÉmilien (perso)
2023-09-27[fix] engine brave - fetch traits (modified settings menu)Markus Heiser
Brave has changed it settings menu fundamental. Region codes are no longer in the HTML page, we have to read the regional codes from a JS: https://cdn.search.brave.com/serp/v2/_app/immutable/chunks/parameters.734c106a.js Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-09-21[fix] engine - brave don't show adsjazzzooo
2023-09-18[fix] spellingjazzzooo
2023-09-15[fix] brave.videosjazzzooo
2023-09-15[fix] brave.newsjazzzooo
2023-09-12[fix] engine - bravejazzzooo
2023-09-09Replace chompjs with pure Python codeAlexandre Flament
The new implementation is good enough for the current usage (brave)
2023-08-18[mod] brave: support for showing the answer source urlBnyro
2023-08-10[mod] engine brave: raise error on unsupported categoryBnyro
2023-08-08[mod] brave engines: add fetch_traits() / improve language supportMarkus Heiser
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-08-08[mod] implement brave (WEB) engine to replace XPath configurationMarkus Heiser
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-08-08[feat] engine: brave - support for newsBnyro
2023-08-08[feat] engine: brave - support for videosBnyro
2023-08-08[feat] engine: brave - support for imagesBnyro