.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 init (self, "flask.Flask" app)
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, typing.Any other)
bool pre_search (self, SXNG_Request request, "SearchWithPlugins" search)
None|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 50 of file tracker_url_remover.py.

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

◆ init()

bool searx.plugins.tracker_url_remover.SXNGPlugin.init ( self,
"flask.Flask" app )
Initialization of the plugin, the return value decides whether this
plugin is active or not.  Initialization only takes place once, at the
time the WEB application is set up.  The base method always returns
``True``, the method can be overwritten in the inheritances,

- ``True`` plugin is active
- ``False`` plugin is inactive

Reimplemented from searx.plugins._core.Plugin.

Definition at line 40 of file tracker_url_remover.py.

40 def init(self, app: "flask.Flask") -> bool:
41 TRACKER_PATTERNS.init()
42 return True
43

Referenced by searx.sqlitedb.SQLiteAppl.connect(), and searx.sqlitedb.SQLiteAppl.DB().

Here is the caller graph for this function:

◆ 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 44 of file tracker_url_remover.py.

44 def on_result(self, request: "SXNG_Request", search: "SearchWithPlugins", result: "Result") -> bool:
45
46 result.filter_urls(self.filter_url_field)
47 return True
48

Member Data Documentation

◆ filter_url_field

searx.plugins.tracker_url_remover.SXNGPlugin.filter_url_field

Definition at line 46 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: