Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
666046bdd1 | ||
|
|
e9559f3248 |
@@ -13,16 +13,12 @@ from aioweb import Response
|
|||||||
from aioweb_tls import CurlCffi, TLSSession
|
from aioweb_tls import CurlCffi, TLSSession
|
||||||
from fake_useragent import UserAgent
|
from fake_useragent import UserAgent
|
||||||
|
|
||||||
from monitor_utils.constants import CLIENT_IDENTIFIERS, RETRY_LIMIT, TIMEOUT_SECONDS
|
from monitor_utils.constants import CLIENT_IDENTIFIERS, RETRY_LIMIT
|
||||||
|
|
||||||
UA = UserAgent()
|
UA = UserAgent()
|
||||||
|
|
||||||
|
|
||||||
def get_default_session(
|
def get_default_session(proxies: AioProxies, headers: dict | None = None) -> TLSSession:
|
||||||
proxies: AioProxies,
|
|
||||||
headers: dict | None = None,
|
|
||||||
timeout: int = TIMEOUT_SECONDS,
|
|
||||||
) -> TLSSession:
|
|
||||||
"""Return a TLSSession impersonating a random client fingerprint.
|
"""Return a TLSSession impersonating a random client fingerprint.
|
||||||
|
|
||||||
Fingerprint rotation lives here so every monitor rotates the same way; the
|
Fingerprint rotation lives here so every monitor rotates the same way; the
|
||||||
@@ -40,9 +36,6 @@ def get_default_session(
|
|||||||
monitor-wide static headers; per-request headers still go through
|
monitor-wide static headers; per-request headers still go through
|
||||||
send_request. The curl_cffi impersonation already supplies a
|
send_request. The curl_cffi impersonation already supplies a
|
||||||
matching User-Agent, so one is not defaulted here.
|
matching User-Agent, so one is not defaulted here.
|
||||||
timeout: Total request timeout in seconds, defaulting to TIMEOUT_SECONDS.
|
|
||||||
aioweb's own default is only 10s, so this restores the wider budget
|
|
||||||
the old sessions used and slow retailers depend on.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A TLSSession over a curl_cffi backend with a random impersonation, with
|
A TLSSession over a curl_cffi backend with a random impersonation, with
|
||||||
@@ -52,9 +45,7 @@ def get_default_session(
|
|||||||
headers = headers or {}
|
headers = headers or {}
|
||||||
headers.setdefault("User-Agent", UA.chrome)
|
headers.setdefault("User-Agent", UA.chrome)
|
||||||
impersonate = random.choice(CLIENT_IDENTIFIERS)
|
impersonate = random.choice(CLIENT_IDENTIFIERS)
|
||||||
session = TLSSession(
|
session = TLSSession(backend=CurlCffi(impersonate=impersonate), headers=headers)
|
||||||
backend=CurlCffi(impersonate=impersonate), headers=headers, timeout=timeout
|
|
||||||
)
|
|
||||||
session.proxy_pool = proxies
|
session.proxy_pool = proxies
|
||||||
return session
|
return session
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user