mirror of
https://github.com/searxng/searxng.git
synced 2025-12-22 11:40:01 +00:00
[fix] engine ahmia blacklist, arch linux: use proper searxng user agent including version (#5414)
This commit is contained in:
@@ -12,7 +12,7 @@ from urllib.parse import urlencode, urljoin, urlparse
|
||||
import lxml
|
||||
import babel
|
||||
|
||||
from searx.utils import extract_text, eval_xpath_list, eval_xpath_getindex
|
||||
from searx.utils import extract_text, eval_xpath_list, eval_xpath_getindex, searxng_useragent
|
||||
from searx.enginelib.traits import EngineTraits
|
||||
from searx.locales import language_tag
|
||||
|
||||
@@ -45,7 +45,7 @@ def request(query, params):
|
||||
query += ' (' + eng_lang + ')'
|
||||
# wiki.archlinux.org is protected by anubis
|
||||
# - https://github.com/searxng/searxng/issues/4646#issuecomment-2817848019
|
||||
params['headers']['User-Agent'] = "SearXNG"
|
||||
params['headers']['User-Agent'] = searxng_useragent()
|
||||
elif netloc == 'wiki.archlinuxcn.org':
|
||||
base_url = 'https://' + netloc + '/wzh/index.php?'
|
||||
|
||||
|
||||
@@ -12,13 +12,14 @@ Output file: :origin:`searx/data/ahmia_blacklist.txt` (:origin:`CI Update data
|
||||
|
||||
import requests
|
||||
from searx.data import data_dir
|
||||
from searx.utils import searxng_useragent
|
||||
|
||||
DATA_FILE = data_dir / 'ahmia_blacklist.txt'
|
||||
URL = 'https://ahmia.fi/blacklist/banned/'
|
||||
|
||||
|
||||
def fetch_ahmia_blacklist():
|
||||
resp = requests.get(URL, timeout=3.0, headers={"User-Agent": "SearXNG"})
|
||||
resp = requests.get(URL, timeout=3.0, headers={"User-Agent": searxng_useragent()})
|
||||
if resp.status_code != 200:
|
||||
# pylint: disable=broad-exception-raised
|
||||
raise Exception("Error fetching Ahmia blacklist, HTTP code " + str(resp.status_code))
|
||||
|
||||
Reference in New Issue
Block a user