mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
改进创建ResponseData逻辑
This commit is contained in:
parent
322ee10bd0
commit
57b46e7b26
@ -1204,16 +1204,20 @@ class NetworkListener(object):
|
|||||||
request_id = kwargs['requestId']
|
request_id = kwargs['requestId']
|
||||||
if request_id in self._requests:
|
if request_id in self._requests:
|
||||||
try:
|
try:
|
||||||
body = self._page.run_cdp('Network.getResponseBody', requestId=request_id)['body']
|
r = self._page.run_cdp('Network.getResponseBody', requestId=request_id)
|
||||||
except:
|
body = r['body']
|
||||||
body = None
|
is_base64 = r['base64Encoded']
|
||||||
|
except CallMethodError:
|
||||||
|
body = ''
|
||||||
|
is_base64 = False
|
||||||
|
|
||||||
request = self._requests[request_id]
|
request = self._requests[request_id]
|
||||||
target = request['target']
|
target = request['target']
|
||||||
rd = ResponseData(request_id, request['response'],
|
rd = ResponseData(request_id, request['response'],
|
||||||
body, self._page.tab_id, target)
|
body, self._page.tab_id, target)
|
||||||
rd.postData = request['post_data']
|
rd.postData = request['post_data']
|
||||||
rd._requestHeaders = request['request_headers']
|
rd._base64_body = is_base64
|
||||||
|
rd.requestHeaders = request['request_headers']
|
||||||
self._results[target] = rd
|
self._results[target] = rd
|
||||||
|
|
||||||
def _requestWillBeSent(self, **kwargs):
|
def _requestWillBeSent(self, **kwargs):
|
||||||
|
@ -2,7 +2,7 @@ requests
|
|||||||
lxml
|
lxml
|
||||||
cssselect
|
cssselect
|
||||||
DownloadKit>=0.5.3
|
DownloadKit>=0.5.3
|
||||||
FlowViewer>=0.2.10
|
FlowViewer>=0.3.0
|
||||||
websocket-client
|
websocket-client
|
||||||
click
|
click
|
||||||
tldextract
|
tldextract
|
Loading…
x
Reference in New Issue
Block a user