from __future__ import annotations from typing import Union from aiohttp import ClientResponse from requests import Response as RequestsResponse from ..errors import ResponseStatusError, RateLimitError from . import Response, StreamResponse class CloudflareError(ResponseStatusError): ... def is_cloudflare(text: str) -> bool: if "Generated by cloudfront" in text or '
' in text: return True elif "
Unable to load site
" in text or 'id="challenge-error-text"' in text async def raise_for_status_async(response: Union[StreamResponse, ClientResponse], message: str = None): if response.ok: return text = await response.text() if message is None: is_html = response.headers.get("content-type", "").startswith("text/html") or text.startswith("