zbq111 commited on
Commit
4a0f7a6
·
verified ·
1 Parent(s): 7620540

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +12 -4
main.py CHANGED
@@ -3,16 +3,24 @@ from playwright.async_api import BrowserType
3
 
4
  _original_launch = BrowserType.launch
5
 
6
-
7
  async def _patched_launch(self, *args, **kwargs):
8
  custom_proxy = os.environ.get("MY_CUSTOM_PROXY")
9
- print(f"!!! Nova Check: Proxy is {custom_proxy} !!!")
10
  if custom_proxy:
11
- kwargs["proxy"] = {"server": custom_proxy}
 
 
 
 
 
 
 
 
 
 
12
  return await _original_launch(self, *args, **kwargs)
13
 
14
-
15
  BrowserType.launch = _patched_launch
 
16
  """Service entrypoint compatible with Render-style deployment."""
17
 
18
  import os
 
3
 
4
  _original_launch = BrowserType.launch
5
 
 
6
  async def _patched_launch(self, *args, **kwargs):
7
  custom_proxy = os.environ.get("MY_CUSTOM_PROXY")
 
8
  if custom_proxy:
9
+ try:
10
+ auth_part, url_part = custom_proxy.split("@")
11
+ username, password = auth_part.replace("http://", "").split(":")
12
+ server_url = "http://" + url_part
13
+ kwargs["proxy"] = {
14
+ "server": server_url,
15
+ "username": username,
16
+ "password": password
17
+ }
18
+ except Exception as e:
19
+ print(f"Proxy parse error: {e}")
20
  return await _original_launch(self, *args, **kwargs)
21
 
 
22
  BrowserType.launch = _patched_launch
23
+
24
  """Service entrypoint compatible with Render-style deployment."""
25
 
26
  import os