mirror of
https://github.com/searxng/searxng.git
synced 2024-11-29 22:21:02 +00:00
955eab8240
- fix docs/searxng_extra/standalone_searx.py.rst - add SPDX tag - pylint standalone_searx.py and update_wikidata_units.py Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
31 lines
786 B
Python
Executable file
31 lines
786 B
Python
Executable file
#!/usr/bin/env python
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
# This script saves Ahmia's blacklist for onion sites.
|
|
# More info in https://ahmia.fi/blacklist/
|
|
|
|
# set path
|
|
from os.path import join
|
|
|
|
import requests
|
|
from searx import searx_dir
|
|
|
|
URL = 'https://ahmia.fi/blacklist/banned/'
|
|
|
|
|
|
def fetch_ahmia_blacklist():
|
|
resp = requests.get(URL, timeout=3.0)
|
|
if resp.status_code != 200:
|
|
raise Exception("Error fetching Ahmia blacklist, HTTP code " + resp.status_code)
|
|
else:
|
|
blacklist = resp.text.split()
|
|
return blacklist
|
|
|
|
|
|
def get_ahmia_blacklist_filename():
|
|
return join(join(searx_dir, "data"), "ahmia_blacklist.txt")
|
|
|
|
|
|
blacklist = fetch_ahmia_blacklist()
|
|
with open(get_ahmia_blacklist_filename(), "w") as f:
|
|
f.write('\n'.join(blacklist))
|