playwright 执行脚本时监控脚本请求信息
1,编写一个响应方法,用来设置要监控的内容
# xxxx/xx 表示你想监控url中包含某些信息的请求,你也可以不加判断,监控所有
def check_response(response):
response.finished()
if "/xxxxxx/xxx/search" in response.url:
logging.info("URL:{}".format(response.request.url))
logging.info("method:{}".format(response.request.method))
logging.info("status:{}".format(response.status))
logging.info("timing:{} 毫秒".format(response.request.timing['responseEnd']))
2, 使用这个定义好的方法
# 注意:在page定义完成后,直接放那儿就行了
page.on('response',check_response)