改进创建ResponseData逻辑

This commit is contained in:
g1879 2023-04-05 22:42:01 +08:00
parent 322ee10bd0
commit 57b46e7b26
3 changed files with 10 additions and 6 deletions

View File

@ -1204,16 +1204,20 @@ class NetworkListener(object):
request_id = kwargs['requestId']
if request_id in self._requests:
try:
body = self._page.run_cdp('Network.getResponseBody', requestId=request_id)['body']
except:
body = None
r = self._page.run_cdp('Network.getResponseBody', requestId=request_id)
body = r['body']
is_base64 = r['base64Encoded']
except CallMethodError:
body = ''
is_base64 = False
request = self._requests[request_id]
target = request['target']
rd = ResponseData(request_id, request['response'],
body, self._page.tab_id, target)
rd.postData = request['post_data']
rd._requestHeaders = request['request_headers']
rd._base64_body = is_base64
rd.requestHeaders = request['request_headers']
self._results[target] = rd
def _requestWillBeSent(self, **kwargs):

View File

@ -2,7 +2,7 @@ requests
lxml
cssselect
DownloadKit>=0.5.3
FlowViewer>=0.2.10
FlowViewer>=0.3.0
websocket-client
click
tldextract

View File

@ -23,7 +23,7 @@ setup(
'requests',
'cssselect',
'DownloadKit>=0.5.3',
'FlowViewer>=0.2.10',
'FlowViewer>=0.3.0',
'websocket-client',
'click~=8.1.3',
'tldextract'