small cleanup of comments/added optional impersonate into run_bounded_cycle for monitors like bhphoto that need different clients than what we support/dont need to rotate

This commit is contained in:
TPV committed 2026-09-29 18:55:52 -07:00
1 parent 4563cdf920
commit 6720592685
3 files changed
+9 -13

No files matched your search

+7 -1
View File
@@ -13,6 +13,7 @@ import random
from aioproxies import AioProxies
from aioweb import Response
from aioweb_tls import CurlCffi, TLSSession
from curl_cffi.requests.impersonate import BrowserTypeLiteral
from monitor_utils.constants import (
CLIENT_IDENTIFIERS,
MAX_CURL_HANDLES,
@@ -70,6 +71,7 @@ def get_default_session(
headers: dict | None = None,
timeout: int = TIMEOUT_SECONDS,
max_clients: int = MAX_CURL_HANDLES,
impersonate: BrowserTypeLiteral | None = None,
) -> TLSSession:
"""Return a TLSSession impersonating a random client fingerprint.
@@ -98,13 +100,17 @@ def get_default_session(
checkout. Keep it at or above the monitor's real fan-out (the sum
of its pagination semaphores plus any unsemaphored per-cycle
requests) so the wait is never reachable.
impersonate: A curl_cffi profile to pin instead of drawing one from
CLIENT_IDENTIFIERS, for a retailer whose bot protection only
tolerates some profiles from a given IP (B&H's Cloudflare refuses
every chrome profile on a flagged IP but still accepts safari).
Returns:
A BoundedCloseSession (a TLSSession whose close is bounded) over a
curl_cffi backend with a random impersonation, with the proxy pool
attached as proxy_pool.
"""
impersonate = random.choice(CLIENT_IDENTIFIERS)
impersonate = impersonate or random.choice(CLIENT_IDENTIFIERS)
session = BoundedCloseSession(
backend=CurlCffi(impersonate=impersonate),
headers=headers,