Search code examples
c#web-scrapingpuppeteerpuppeteer-sharp

How can I get all network requests and full response data when loading a page by Puppeteer-sharp?


I`m trying to get all network requests (as in the chrome dev tools network tab) by Puppeteer-sharp, like it works with JS Puppeteer:

const page = await browser.newPage();
page.on('response', async (response) => {}

I cant find the solution in documentation of Puppeteer-sharp.


Solution

  • You can use the Response event:

    var page = await browser.NewPageAsync();
    page.Response += (sender, e) => 
    {
        Console.WriteLine(e.Response.Url);
    }