.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.plugins.tracker_url_remover.SXNGPlugin Class Reference
Inheritance diagram for searx.plugins.tracker_url_remover.SXNGPlugin:
Collaboration diagram for searx.plugins.tracker_url_remover.SXNGPlugin:

Public Member Functions

None __init__ (self, "PluginCfg" plg_cfg)
bool on_result (self, "SXNG_Request" request, "SearchWithPlugins" search, Result result)
bool|str filter_url_field (cls, "Result|LegacyResult" result, str field_name, str url_src)
Public Member Functions inherited from searx.plugins._core.Plugin
None __init__ (self, PluginCfg plg_cfg)
int __hash__ (self)
 __eq__ (self, other)
bool init (self, "flask.Flask" app)
bool pre_search (self, SXNG_Request request, "SearchWithPlugins" search)
None|typing.Sequence[Resultpost_search (self, SXNG_Request request, "SearchWithPlugins" search)

Public Attributes

 info
 filter_url_field

Additional Inherited Members

Static Public Attributes inherited from searx.plugins._core.Plugin
str id = ""
typing active .ClassVar[bool]
list keywords = []
logging log .Logger
str fqn = ""

Detailed Description

Remove trackers arguments from the returned URL.

Definition at line 25 of file tracker_url_remover.py.

Constructor & Destructor Documentation

◆ __init__()

None searx.plugins.tracker_url_remover.SXNGPlugin.__init__ ( self,
"PluginCfg" plg_cfg )

Definition at line 30 of file tracker_url_remover.py.

30 def __init__(self, plg_cfg: "PluginCfg") -> None:
31
32 super().__init__(plg_cfg)
33 self.info = PluginInfo(
34 id=self.id,
35 name=gettext("Tracker URL remover"),
36 description=gettext("Remove trackers arguments from the returned URL"),
37 preference_section="privacy",
38 )
39

References __init__().

Referenced by __init__().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ filter_url_field()

bool | str searx.plugins.tracker_url_remover.SXNGPlugin.filter_url_field ( cls,
"Result|LegacyResult" result,
str field_name,
str url_src )
Returns bool ``True`` to use URL unchanged (``False`` to ignore URL).
If URL should be modified, the returned string is the new URL to use.

Definition at line 46 of file tracker_url_remover.py.

46 def filter_url_field(cls, result: "Result|LegacyResult", field_name: str, url_src: str) -> bool | str:
47 """Returns bool ``True`` to use URL unchanged (``False`` to ignore URL).
48 If URL should be modified, the returned string is the new URL to use."""
49
50 if not url_src:
51 log.debug("missing a URL in field %s", field_name)
52 return True
53
54 return TRACKER_PATTERNS.clean_url(url=url_src)

◆ on_result()

bool searx.plugins.tracker_url_remover.SXNGPlugin.on_result ( self,
"SXNG_Request" request,
"SearchWithPlugins" search,
Result result )
Runs for each result of each engine and returns a boolean:

- ``True`` to keep the result
- ``False`` to remove the result from the result list

The ``result`` can be modified to the needs.

.. hint::

   If :py:obj:`Result.url <searx.result_types._base.Result.url>` is modified,
   :py:obj:`Result.parsed_url <searx.result_types._base.Result.parsed_url>` must
   be changed accordingly:

   .. code:: python

      result["parsed_url"] = urlparse(result["url"])

Reimplemented from searx.plugins._core.Plugin.

Definition at line 40 of file tracker_url_remover.py.

40 def on_result(self, request: "SXNG_Request", search: "SearchWithPlugins", result: Result) -> bool:
41
42 result.filter_urls(self.filter_url_field)
43 return True
44

Member Data Documentation

◆ filter_url_field

searx.plugins.tracker_url_remover.SXNGPlugin.filter_url_field

Definition at line 42 of file tracker_url_remover.py.

◆ info

searx.plugins.tracker_url_remover.SXNGPlugin.info
Initial value:
= PluginInfo(
id=self.id,
name=gettext("Tracker URL remover"),
description=gettext("Remove trackers arguments from the returned URL"),
preference_section="privacy",
)

Definition at line 33 of file tracker_url_remover.py.


The documentation for this class was generated from the following file: