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