diff options
| author | Bnyro <bnyro@tutanota.com> | 2026-07-29 17:11:53 +0200 |
|---|---|---|
| committer | Bnyro <bnyro@tutanota.com> | 2026-07-30 14:54:39 +0200 |
| commit | a449518ed410407e9bebefcf45efca50a880d722 (patch) | |
| tree | f94a1f595876489ef2497b1f50297963b82b9e23 /searx | |
| parent | 702f702f9b526c94049113dd33a0b4cf8ea0e116 (diff) | |
[mod] engines: replace [random.choice(...) for ... in range(..)] with random.choices
Diffstat (limited to 'searx')
| -rw-r--r-- | searx/answerers/random.py | 2 | ||||
| -rw-r--r-- | searx/autocomplete.py | 2 | ||||
| -rw-r--r-- | searx/engines/500px.py | 2 | ||||
| -rw-r--r-- | searx/engines/bilibili.py | 2 | ||||
| -rw-r--r-- | searx/engines/swisscows.py | 2 |
5 files changed, 5 insertions, 5 deletions
diff --git a/searx/answerers/random.py b/searx/answerers/random.py index 44b94a0e2..4f7ed515f 100644 --- a/searx/answerers/random.py +++ b/searx/answerers/random.py @@ -16,7 +16,7 @@ from . import Answerer, AnswererInfo def random_characters(): random_string_letters = string.ascii_lowercase + string.digits + string.ascii_uppercase - return [random.choice(random_string_letters) for _ in range(random.randint(8, 32))] + return random.choices(random_string_letters, k=random.randint(8, 32)) def random_string(): diff --git a/searx/autocomplete.py b/searx/autocomplete.py index 9e0c0d84f..2063aec7b 100644 --- a/searx/autocomplete.py +++ b/searx/autocomplete.py @@ -62,7 +62,7 @@ def bing(query: str, _sxng_locale: str) -> list[str]: # bing search autocompleter base_url = "https://www.bing.com/AS/Suggestions?" # cvid has to be a 32 character long string consisting of numbers and uppsercase characters - cvid = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(32)) + cvid = ''.join(random.choices(string.ascii_uppercase + string.digits, k=32)) response = get(base_url + urlencode({'qry': query, 'csr': 1, 'cvid': cvid})) results: list[str] = [] diff --git a/searx/engines/500px.py b/searx/engines/500px.py index 99596c144..583995948 100644 --- a/searx/engines/500px.py +++ b/searx/engines/500px.py @@ -82,7 +82,7 @@ fragment SXNG_query on Query { def setup(_) -> bool: global SXNG_query # pylint: disable=global-statement - rand_str: str = "".join(random.choice(string.ascii_letters) for _ in range(5)) + rand_str: str = "".join(random.choices(string.ascii_letters, k=5)) SXNG_query = SXNG_query.replace("SXNG_query", "PhotoSearchPaginationContainer_query_1" + rand_str) return True diff --git a/searx/engines/bilibili.py b/searx/engines/bilibili.py index 9168bf733..dbd7c6bea 100644 --- a/searx/engines/bilibili.py +++ b/searx/engines/bilibili.py @@ -32,7 +32,7 @@ base_url = "https://api.bilibili.com/x/web-interface/search/type" cookie = { "innersign": "0", - "buvid3": "".join(random.choice(string.hexdigits) for _ in range(16)) + "infoc", + "buvid3": "".join(random.choices(string.hexdigits, k=16)) + "infoc", "i-wanna-go-back": "-1", "b_ut": "7", "FEED_LIVE_VERSION": "V8", diff --git a/searx/engines/swisscows.py b/searx/engines/swisscows.py index 68f1d0bb5..ae10b065b 100644 --- a/searx/engines/swisscows.py +++ b/searx/engines/swisscows.py @@ -92,7 +92,7 @@ def generate_nonce(length: int = 32) -> str: """ Generate a random char sequence with the given length. """ - return "".join([random.choice(NONCE_ALPHABET) for _ in range(length)]) + return "".join(random.choices(NONCE_ALPHABET, k=length)) def caesar_shift_with_switch_case(s: str, offset: int = 13) -> str: |
