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

Public Member Functions

None __init__ (self, "PluginCfg" plg_cfg)
bool on_result (self, "SXNG_Request" request, "SearchWithPlugins" search, "Result" result)
bool init (self, "flask.Flask" app)
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

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

Filter out onion results that appear in Ahmia's blacklist (See https://ahmia.fi/blacklist).

Definition at line 24 of file ahmia_filter.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 29 of file ahmia_filter.py.

29 def __init__(self, plg_cfg: "PluginCfg") -> None:
30 super().__init__(plg_cfg)
31 self.info = PluginInfo(
32 id=self.id,
33 name=gettext("Ahmia blacklist"),
34 description=gettext("Filter out onion results that appear in Ahmia's blacklist."),
35 preference_section="general",
36 )
37

References __init__().

Referenced by __init__().

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

Member Function Documentation

◆ init()

bool searx.plugins.ahmia_filter.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 46 of file ahmia_filter.py.

46 def init(self, app: "flask.Flask") -> bool: # pylint: disable=unused-argument
47 global ahmia_blacklist # pylint: disable=global-statement
48 if not get_setting("outgoing.using_tor_proxy"):
49 # disable the plugin
50 return False
51 ahmia_blacklist = ahmia_blacklist_loader()
52 return True

References searx.get_setting().

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

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

◆ on_result()

bool searx.plugins.ahmia_filter.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 38 of file ahmia_filter.py.

40 ) -> bool: # pylint: disable=unused-argument
41 if not getattr(result, "is_onion", False) or not getattr(result, "parsed_url", False):
42 return True
43 result_hash = md5(result["parsed_url"].hostname.encode()).hexdigest()
44 return result_hash not in ahmia_blacklist
45

Member Data Documentation

◆ info

searx.plugins.ahmia_filter.SXNGPlugin.info
Initial value:
= PluginInfo(
id=self.id,
name=gettext("Ahmia blacklist"),
description=gettext("Filter out onion results that appear in Ahmia's blacklist."),
preference_section="general",
)

Definition at line 31 of file ahmia_filter.py.


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