Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -27,12 +27,12 @@ def get_root_domain(url):
|
|
27 |
return domain
|
28 |
|
29 |
# 网络抓包内容过滤
|
30 |
-
def filter_type(
|
31 |
types = [
|
32 |
'application/javascript', 'application/x-javascript', 'text/css', 'webp', 'image/png', 'image/gif',
|
33 |
'image/jpeg', 'image/x-icon', 'application/octet-stream'
|
34 |
]
|
35 |
-
if
|
36 |
return True
|
37 |
return False
|
38 |
|
@@ -135,7 +135,7 @@ def chrome(url:str=None,wait:int=5,header:str=None,cookie:str=None):
|
|
135 |
if message.get('method') != 'Network.responseReceived': # 如果method 不是 responseReceived 类型就不往下执行
|
136 |
continue
|
137 |
packet_type = message.get('params').get('response').get('mimeType') # 获取该请求返回的type
|
138 |
-
if not filter_type(packet_type): # 过滤type
|
139 |
continue
|
140 |
requestId = message.get('params').get('requestId') # 唯一的请求标识符。相当于该请求的身份证
|
141 |
url = message.get('params').get('response').get('url') # 获取 该请求 url
|
|
|
27 |
return domain
|
28 |
|
29 |
# 网络抓包内容过滤
|
30 |
+
def filter_type(_type: str):
|
31 |
types = [
|
32 |
'application/javascript', 'application/x-javascript', 'text/css', 'webp', 'image/png', 'image/gif',
|
33 |
'image/jpeg', 'image/x-icon', 'application/octet-stream'
|
34 |
]
|
35 |
+
if _type not in types:
|
36 |
return True
|
37 |
return False
|
38 |
|
|
|
135 |
if message.get('method') != 'Network.responseReceived': # 如果method 不是 responseReceived 类型就不往下执行
|
136 |
continue
|
137 |
packet_type = message.get('params').get('response').get('mimeType') # 获取该请求返回的type
|
138 |
+
if not filter_type(_type=packet_type): # 过滤type
|
139 |
continue
|
140 |
requestId = message.get('params').get('requestId') # 唯一的请求标识符。相当于该请求的身份证
|
141 |
url = message.get('params').get('response').get('url') # 获取 该请求 url
|