File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,11 +28,12 @@ async def download_image(
2828 attempts = retry_attempts , start_timeout = 3.0 , max_timeout = timeout
2929 )
3030
31+ px = self ._parent .proxy if isinstance (self ._parent .proxy , Proxy ) else Proxy (self ._parent .proxy )
3132 async with RetryClient (retry_options = retry_options ) as retry_client :
3233 async with retry_client .get (
3334 url ,
3435 raise_for_status = True ,
35- proxy = Proxy ( self . _parent . proxy ) .as_str (),
36+ proxy = px .as_str (),
3637 ) as resp :
3738 body = await resp .read ()
3839 file = BytesIO (body )
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ class ChizhikAPI(ApiParent):
3131 """Время ожидания ответа от сервера в миллисекундах."""
3232 headless : bool = True
3333 """Запускать браузер в headless режиме?"""
34- proxy : str | dict | None = field (default_factory = Proxy .from_env )
34+ proxy : str | dict | Proxy | None = field (default_factory = Proxy .from_env )
3535 """Прокси-сервер для всех запросов (если нужен). По умолчанию берет из окружения (если есть).
3636 Принимает как формат Playwright, так и строчный формат."""
3737 browser_opts : dict [str , Any ] = field (default_factory = dict )
@@ -68,10 +68,12 @@ async def __aenter__(self):
6868 # Прогрев сессии (headless ➜ cookie `session` ➜ accessToken)
6969 async def _warmup (self ) -> None :
7070 """Прогрев сессии через браузер для получения человекоподобности."""
71+ px = self .proxy if isinstance (self .proxy , Proxy ) else Proxy (self .proxy )
7172 br = await AsyncCamoufox (
7273 headless = self .headless ,
73- proxy = Proxy ( self . proxy ) .as_dict (),
74+ proxy = px .as_dict (),
7475 ** self .browser_opts ,
76+ block_images = True ,
7577 ).start ()
7678
7779 self .session = HumanBrowser .replace (br )
You can’t perform that action at this time.
0 commit comments