Capturing network requests using Puppeteer?
I want to capture any requests, which include
.m3u8
in their URL, but its neither captured by the normal requestInterception nor using the createCDPSession
method. In the normal chrome devtools, the master.m3u8
shows up, but my program cant catch it for some reason. I also tried using Astral, but the it also didn't capture the request.
Using createDCPSession
:
Using normal requestInterception:
3 Replies
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the code snippets you've provided, I can offer some general advice, but please note that this advice is not based on the Deno documentation, and you should double-check the accuracy of the advice given.
In your
createCDPSession
code, you are using a lot of events, but not all of them are related to network requests. If you are specifically looking to capture network requests that include .m3u8
in their URL, you should focus on the Network.requestWillBeSent
event, which is triggered when a network request is about to be sent. You can then inspect the request
object to check if the URL contains .m3u8
.
Here's a simplified version of the event listener that you might use:
For the normal request interception code, your approach seems correct. You are setting up request interception and logging the URL of each request. If .m3u8
requests are not being captured, it could be due to several reasons, such as the requests being made by a service worker, or the requests not being initiated by the main page.
Please ensure that the page.setRequestInterception(true);
is set before any network activity occurs, as this can sometimes cause issues if set too late.
Remember to verify the paths you are using for the --disable-extensions-except
and --load-extension
arguments, as incorrect paths could cause unexpected behavior.
Since this is not an exhaustive solution and is not based on the Deno documentation, I recommend further investigation and testing to pinpoint the issue. You may also want toconsult the Puppeteer documentation or community for more specific guidance on capturing network requests with
.m3u8
URLs.Also, if that matters, the master.m3u8 is requested from inside an iframe