How to log network requests
Contributors: Meir Blachman
Problem
Section titled “Problem”You need to monitor the outgoing network requests.
Solution
Section titled “Solution”Use Page.Request event to monitor network requests.
using var browser = await Puppeteer.LaunchAsync(new () { Headless = true });var page = await browser.NewPageAsync();page.Request += (sender, e) =>{ Console.WriteLine($"Request: {e.Request.Method} {e.Request.Url}"); foreach (var header in e.Request.Headers) { Console.WriteLine($"{header.Key}: {header.Value}"); }};await page.GoToAsync("https://example.com");Made with love by Dario Kondratiuk