我正在修补名为的无头 chrome 节点 apipuppeteer
.
我想知道如何听取特定的请求响应以及如何采取行动。
我已经查看了事件requestfinish
and response
但它给了我all页面中已执行的请求/响应。
我怎样才能实现评论行为?
一种选择是执行以下操作:
page.on('response', response => {
if (response.url().endsWith("your/match"))
console.log("response code: ", response.status());
// do something here
});
这仍然捕获所有请求,但允许您过滤事件发射器并对其进行操作。
https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#event-response https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#event-response
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)