.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, other)
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 26 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 31 of file tracker_url_remover.py.

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

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

51 def filter_url_field(cls, result: "Result|LegacyResult", field_name: str, url_src: str) -> bool | str:
52 """Returns bool ``True`` to use URL unchanged (``False`` to ignore URL).
53 If URL should be modified, the returned string is the new URL to use."""
54
55 if not url_src:
56 log.debug("missing a URL in field %s", field_name)
57 return True
58
59 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 41 of file tracker_url_remover.py.

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

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

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

Member Data Documentation

◆ filter_url_field

searx.plugins.tracker_url_remover.SXNGPlugin.filter_url_field

Definition at line 47 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 34 of file tracker_url_remover.py.


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