Update api.txt
Browse files
api.txt
CHANGED
|
@@ -342,12 +342,36 @@ async def open_browser(request: Request):
|
|
| 342 |
|
| 343 |
profile_dir = f"{PROFILE_BASE}/{browser_id}"
|
| 344 |
os.makedirs(profile_dir, exist_ok=True)
|
| 345 |
-
#
|
| 346 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 347 |
args = [CHROME_PATH, f"--remote-debugging-port={port}", f"--user-data-dir={profile_dir}"]
|
| 348 |
-
# 加入默认参数
|
| 349 |
logger.info(f"使用默认参数: {get_default_launch_args()}")
|
| 350 |
args.extend(get_default_launch_args())
|
|
|
|
|
|
|
| 351 |
if launch_args:
|
| 352 |
# 拆分参数并去重,保留顺序
|
| 353 |
base_args = args[1:] # 除去chrome可执行文件
|
|
@@ -627,3 +651,4 @@ async def cdp_native_ws_proxy(websocket: WebSocket, tab_type: str, target_id: st
|
|
| 627 |
|
| 628 |
if __name__ == "__main__":
|
| 629 |
uvicorn.run("api:app", host="0.0.0.0", port=7860, reload=True)
|
|
|
|
|
|
| 342 |
|
| 343 |
profile_dir = f"{PROFILE_BASE}/{browser_id}"
|
| 344 |
os.makedirs(profile_dir, exist_ok=True)
|
| 345 |
+
# 解析指纹参数
|
| 346 |
+
browser_fp = data.get("browserFingerPrint", {})
|
| 347 |
+
launch_args = browser_fp.get("launchArgs", "")
|
| 348 |
+
|
| 349 |
+
# 解析代理参数
|
| 350 |
+
proxy_type = data.get("proxyType", "").lower()
|
| 351 |
+
host = data.get("host", "")
|
| 352 |
+
proxy_port = data.get("port", "")
|
| 353 |
+
proxy_user = data.get("proxyUserName", "")
|
| 354 |
+
proxy_pass = data.get("proxyPassword", "")
|
| 355 |
+
|
| 356 |
+
proxy_arg = ""
|
| 357 |
+
if proxy_type and host and proxy_port:
|
| 358 |
+
# 组装协议前缀
|
| 359 |
+
if proxy_type in ["http", "https", "socks5", "socks4"]:
|
| 360 |
+
prefix = proxy_type
|
| 361 |
+
else:
|
| 362 |
+
prefix = "http"
|
| 363 |
+
# 组装代理地址
|
| 364 |
+
if proxy_user and proxy_pass:
|
| 365 |
+
proxy_url = f"{prefix}://{proxy_user}:{proxy_pass}@{host}:{proxy_port}"
|
| 366 |
+
else:
|
| 367 |
+
proxy_url = f"{prefix}://{host}:{proxy_port}"
|
| 368 |
+
proxy_arg = f"--proxy-server={proxy_url}"
|
| 369 |
+
|
| 370 |
args = [CHROME_PATH, f"--remote-debugging-port={port}", f"--user-data-dir={profile_dir}"]
|
|
|
|
| 371 |
logger.info(f"使用默认参数: {get_default_launch_args()}")
|
| 372 |
args.extend(get_default_launch_args())
|
| 373 |
+
if proxy_arg:
|
| 374 |
+
args.append(proxy_arg)
|
| 375 |
if launch_args:
|
| 376 |
# 拆分参数并去重,保留顺序
|
| 377 |
base_args = args[1:] # 除去chrome可执行文件
|
|
|
|
| 651 |
|
| 652 |
if __name__ == "__main__":
|
| 653 |
uvicorn.run("api:app", host="0.0.0.0", port=7860, reload=True)
|
| 654 |
+
|