fixed logs
This commit is contained in:
parent
c19c91bb81
commit
41e42e8b57
|
@ -125,21 +125,22 @@ class StolichkiDriver(webdriver.Chrome):
|
|||
self.add_cookie(new_cookie)
|
||||
|
||||
def get_network_response(self, url_mask):
|
||||
logs = self.get_log("performance")[self.last_resp_index:]
|
||||
logs = self.get_log("performance")
|
||||
|
||||
url_mask = re.compile(url_mask)
|
||||
body = None
|
||||
|
||||
for log in filter(lambda log: self.__filter_logs(log), logs):
|
||||
message = json.loads(log.get("message"))['message']
|
||||
|
||||
request_id = message["params"]["requestId"]
|
||||
resp_url = message["params"]["response"]["url"]
|
||||
|
||||
if re.fullmatch(url_mask, resp_url) and self.last_resp_url != resp_url:
|
||||
self.last_resp_index = logs.index(log)
|
||||
self.last_resp_url = resp_url
|
||||
body = self.execute_cdp_cmd("Network.getResponseBody", {"requestId": request_id})
|
||||
return json.loads(body['body'])
|
||||
if re.fullmatch(url_mask, resp_url):
|
||||
body_ = self.execute_cdp_cmd("Network.getResponseBody", {"requestId": request_id})
|
||||
body = json.loads(body_['body'])
|
||||
|
||||
return None
|
||||
return body
|
||||
|
||||
def __filter_logs(self, log):
|
||||
message = json.loads(log.get("message"))['message']
|
||||
|
|
Loading…
Reference in New Issue