首页 > 解决方案 > puppeteer - how to intercept requests and responses only from a certain url in nodejs

问题描述

I'm using puppeteer to automatize spotify login and tracks search and play from a node cli script. since I'm intercepting requests, I want to log only the urls like the one above

https://audio-akp-quic-control-spotify-com.akamaized.net/audio/cb8daa71ccc075db7c559871bdc4?__token__=exp=1614258319~hmac=30c6d8c5676fb472ec33fd5c8ca6331ee756daf9f69096e214

Usually in a chrome extension I can use a glob to target only the desired url for example: https://audio-akp-quic-control-spotify-com.akamaized.net/audio/*, how I can achive the same result in node and log only the request / responses from the urls I need?

标签: node.jspuppeteer

解决方案


推荐阅读