added ability to set default user agent #2

Merged
TPV merged 1 commits from aioweb-migration into main 2026-07-19 04:33:03 +00:00
Showing only changes of commit 20ad4c6535 - Show all commits
+6 -3
View File
@@ -11,13 +11,14 @@ import random
from aioproxies import AioProxies
from aioweb import Response
from aioweb_tls import CurlCffi, TLSSession
from fake_useragent import UserAgent
from monitor_utils.constants import CLIENT_IDENTIFIERS, RETRY_LIMIT
UA = UserAgent()
def get_default_session(
proxies: AioProxies, headers: dict | None = None
) -> TLSSession:
def get_default_session(proxies: AioProxies, headers: dict | None = None) -> TLSSession:
"""Return a TLSSession impersonating a random client fingerprint.
Fingerprint rotation lives here so every monitor rotates the same way; the
@@ -41,6 +42,8 @@ def get_default_session(
the proxy pool attached as proxy_pool.
"""
headers = headers or {}
headers.setdefault("User-Agent", UA.chrome)
impersonate = random.choice(CLIENT_IDENTIFIERS)
session = TLSSession(backend=CurlCffi(impersonate=impersonate), headers=headers)
session.proxy_pool = proxies