CoolFace
Apppublic

fvps/loop4

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
schemas.py45 linesDownload Raw Back to root
1import os
2from enum import Enum
3from typing import Any, Dict, Optional
4from pydantic import BaseModel, HttpUrl, conint
5from curl_cffi.requests import BrowserTypeLiteral
6from typing import get_args
7
8
9BROWSER_TYPES = get_args(BrowserTypeLiteral)
10API_KEY_EXPECTED = os.getenv("PROXY_API_KEY", "")
11_browsers = [
12    "chrome99", "chrome100", "chrome101", "chrome104", "chrome107",
13    "chrome110", "chrome116", "chrome119", "chrome120", "chrome123",
14    "chrome124", "chrome131", "chrome133a", "chrome136", "chrome99_android", "chrome131_android",
15    "edge99", "edge101", "safari15_3",
16    "safari15_3", "safari15_5", "safari17_0", "safari17_2_ios", "safari18_0", "safari18_0_ios",
17    "safari18_4", "safari18_4_ios", "firefox133", "tor145"
18]
19
20
21class HTTPMethod(str, Enum):
22    GET = "GET"
23    POST = "POST"
24    PUT = "PUT"
25    DELETE = "DELETE"
26    PATCH = "PATCH"
27    HEAD = "HEAD"
28    OPTIONS = "OPTIONS"
29
30
31class ProxyRequest(BaseModel):
32    method: HTTPMethod
33    url: HttpUrl
34    params: Optional[Dict[str, str]] = None
35    headers: Optional[Dict[str, str]] = None
36    data: Optional[Any] = None        # form / json / bytes
37    cookies: Optional[Dict[str, str]] = None
38    impersonate: Optional[str] = None
39    proxies: Optional[Dict[str, str]] = None
40    timeout_ms: Optional[conint(ge=100, le=120_000)] = 10_000  # 默认10s
41    return_data: bool = True
42    stream: bool = False                 # 是否返回二进制
43    apikey: Optional[str] = None
44    proxy_chain: list = []            # 剩余链路(URL 列表)
45