mirror of
https://github.com/searxng/searxng.git
synced 2026-05-07 18:03:51 +02:00
[fix] google: switch to using "Google Go App" (NSTNWV) useragent
This commit is contained in:
+2661
-2598
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -13,7 +13,7 @@ from collections.abc import MutableMapping, Callable
|
|||||||
|
|
||||||
from numbers import Number
|
from numbers import Number
|
||||||
from os.path import splitext, join
|
from os.path import splitext, join
|
||||||
from random import choice, randint
|
from random import choice
|
||||||
from html.parser import HTMLParser
|
from html.parser import HTMLParser
|
||||||
from html import escape
|
from html import escape
|
||||||
from urllib.parse import urljoin, urlparse, parse_qs, urlencode
|
from urllib.parse import urljoin, urlparse, parse_qs, urlencode
|
||||||
@@ -82,11 +82,11 @@ def gen_useragent(os_string: str | None = None) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def gen_gsa_useragent() -> str:
|
def gen_gsa_useragent() -> str:
|
||||||
"""Return a random "Android Google App" User Agent suitable for Google
|
"""Return a random "Google Go App" User Agent suitable for Google
|
||||||
|
|
||||||
See searx/data/gsa_useragents.txt
|
See searx/data/gsa_useragents.txt
|
||||||
"""
|
"""
|
||||||
return choice(gsa_useragents_loader()) + " GoogleApp/" + str(randint(0, 9))
|
return choice(gsa_useragents_loader()) + " NSTNWV"
|
||||||
|
|
||||||
|
|
||||||
class HTMLTextExtractor(HTMLParser):
|
class HTMLTextExtractor(HTMLParser):
|
||||||
|
|||||||
@@ -26,7 +26,12 @@ def fetch_gsa_useragents() -> list[str]:
|
|||||||
|
|
||||||
suas: set[str] = set()
|
suas: set[str] = set()
|
||||||
for ua in loads(decompress(response.content)):
|
for ua in loads(decompress(response.content)):
|
||||||
if "Android" in ua["userAgent"] and "Chrome" in ua["userAgent"] and "Samsung" not in ua["userAgent"]:
|
if (
|
||||||
|
"Android" in ua["userAgent"]
|
||||||
|
and "Chrome" in ua["userAgent"]
|
||||||
|
and "Samsung" not in ua["userAgent"]
|
||||||
|
and "Android 10; K" not in ua["userAgent"]
|
||||||
|
):
|
||||||
suas.add(ua["userAgent"])
|
suas.add(ua["userAgent"])
|
||||||
|
|
||||||
luas = list(suas)
|
luas = list(suas)
|
||||||
|
|||||||
Reference in New Issue
Block a user