Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -123,7 +123,7 @@ def chrome(url:str=None,wait:int=5,header:str=None,cookie:str=None):
|
|
123 |
# 完全加载完成时,页面是否有发生过 301 302 跳转过
|
124 |
is_jump = (target_url != current_url)
|
125 |
|
126 |
-
performance_log =
|
127 |
for packet in performance_log:
|
128 |
message = json.loads(packet.get('message')).get('message') # 获取message的数据
|
129 |
if message.get('method') != 'Network.responseReceived': # 如果method 不是 responseReceived 类型就不往下执行
|
@@ -134,7 +134,7 @@ def chrome(url:str=None,wait:int=5,header:str=None,cookie:str=None):
|
|
134 |
requestId = message.get('params').get('requestId') # 唯一的请求标识符。相当于该请求的身份证
|
135 |
url = message.get('params').get('response').get('url') # 获取 该请求 url
|
136 |
try:
|
137 |
-
resp =
|
138 |
print(f'type: {packet_type} url: {url}')
|
139 |
print(f'response: {resp}')
|
140 |
print()
|
|
|
123 |
# 完全加载完成时,页面是否有发生过 301 302 跳转过
|
124 |
is_jump = (target_url != current_url)
|
125 |
|
126 |
+
performance_log = driver.get_log('performance') # 获取名称为 performance 的日志
|
127 |
for packet in performance_log:
|
128 |
message = json.loads(packet.get('message')).get('message') # 获取message的数据
|
129 |
if message.get('method') != 'Network.responseReceived': # 如果method 不是 responseReceived 类型就不往下执行
|
|
|
134 |
requestId = message.get('params').get('requestId') # 唯一的请求标识符。相当于该请求的身份证
|
135 |
url = message.get('params').get('response').get('url') # 获取 该请求 url
|
136 |
try:
|
137 |
+
resp = driver.execute_cdp_cmd('Network.getResponseBody', {'requestId': requestId}) # selenium调用 cdp
|
138 |
print(f'type: {packet_type} url: {url}')
|
139 |
print(f'response: {resp}')
|
140 |
print()
|