mirror of
https://github.com/searxng/searxng.git
synced 2026-09-11 16:56:05 +00:00
[fix] engines: tusksearch referer header
This commit is contained in:
@@ -13,7 +13,7 @@ from dateutil import parser
|
|||||||
|
|
||||||
from searx.exceptions import SearxEngineAPIException
|
from searx.exceptions import SearxEngineAPIException
|
||||||
from searx.network import get
|
from searx.network import get
|
||||||
from searx.utils import gen_useragent, html_to_text
|
from searx.utils import html_to_text
|
||||||
from searx.result_types import EngineResults
|
from searx.result_types import EngineResults
|
||||||
|
|
||||||
if t.TYPE_CHECKING:
|
if t.TYPE_CHECKING:
|
||||||
@@ -52,7 +52,7 @@ def _obtain_x_sid() -> tuple[str, str]:
|
|||||||
The header key is usually called `x-sid-{UUIDv4}`, and the value is
|
The header key is usually called `x-sid-{UUIDv4}`, and the value is
|
||||||
usually a plain UUIDv4 (but a different one than in the header key).
|
usually a plain UUIDv4 (but a different one than in the header key).
|
||||||
"""
|
"""
|
||||||
resp = get(f"{api_url}/revcontent/embed.js", headers={"User-Agent": gen_useragent()})
|
resp = get(f"{api_url}/revcontent/embed.js", headers={"Referer": "https://tusksearch.com/"})
|
||||||
if not resp.ok:
|
if not resp.ok:
|
||||||
raise SearxEngineAPIException("failed to obtain request x-sid token")
|
raise SearxEngineAPIException("failed to obtain request x-sid token")
|
||||||
|
|
||||||
@@ -95,6 +95,7 @@ def request(query: str, params: "OnlineParams") -> None:
|
|||||||
# required - we send a random longitude and latitude instead of the actual user location
|
# required - we send a random longitude and latitude instead of the actual user location
|
||||||
"x-lon": str(round(random.random() * 90, 4)),
|
"x-lon": str(round(random.random() * 90, 4)),
|
||||||
"x-lat": str(round(random.random() * 90, 4)),
|
"x-lat": str(round(random.random() * 90, 4)),
|
||||||
|
"Referer": "https://tusksearch.com/",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user