Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ from fastapi import FastAPI, Request
|
|
4 |
import uvicorn
|
5 |
import time
|
6 |
import json
|
7 |
-
from urllib.parse import unquote, urlparse,
|
8 |
|
9 |
app = FastAPI()
|
10 |
|
@@ -91,16 +91,18 @@ def chrome(url:str=None,wait:int=5,header:str=None,cookie:str=None,cookie_domain
|
|
91 |
if 'cookie' in header_array:
|
92 |
cookie_array = convert_cookies_to_dict(header_array['cookie'])
|
93 |
del header_array['cookie']
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
for key, value in cookie_array.items():
|
95 |
try:
|
96 |
-
|
97 |
-
domain = cookie_domain
|
98 |
-
else:
|
99 |
-
domain = f'.{target_domain}'
|
100 |
-
driver.add_cookie({"name": key, "value": quote(value), "domain": domain, "path": "/"})
|
101 |
except Exception as e:
|
102 |
print("Error Cookie:")
|
103 |
-
print({"name": key, "value":
|
104 |
|
105 |
# 把下次访问中的请求头修改成我们需要的样式(没有修改的项目则保持原样)
|
106 |
driver.header_overrides = header_array
|
|
|
4 |
import uvicorn
|
5 |
import time
|
6 |
import json
|
7 |
+
from urllib.parse import unquote, urlparse, quote_plus
|
8 |
|
9 |
app = FastAPI()
|
10 |
|
|
|
91 |
if 'cookie' in header_array:
|
92 |
cookie_array = convert_cookies_to_dict(header_array['cookie'])
|
93 |
del header_array['cookie']
|
94 |
+
|
95 |
+
if type(cookie_domain) == str:
|
96 |
+
domain = cookie_domain
|
97 |
+
else:
|
98 |
+
domain = f'.{target_domain}'
|
99 |
+
|
100 |
for key, value in cookie_array.items():
|
101 |
try:
|
102 |
+
driver.add_cookie({"name": key, "value": quote_plus(value), "domain": domain, "path": "/"})
|
|
|
|
|
|
|
|
|
103 |
except Exception as e:
|
104 |
print("Error Cookie:")
|
105 |
+
print({"name": key, "value": quote_plus(value), "domain": domain, "path": "/"})
|
106 |
|
107 |
# 把下次访问中的请求头修改成我们需要的样式(没有修改的项目则保持原样)
|
108 |
driver.header_overrides = header_array
|