var browser = await Puppeteer.LaunchAsync(new LaunchOptions { IgnoreDefaultArgs = true, Args = new[] { "--disable-extensions" }, Headless = false, IgnoreHTTPSErrors = true, Timeout = 0 }); using (var page = await browser.NewPageAsync()) { try { await page.GoToAsync(url, timeout: 60000); await page.Keyboard.PressAsync("Enter"); //clear pop ups await Task.Delay(10000); //get html var content = await page.GetContentAsync(); //get screenshot Stream _stream = await page.ScreenshotStreamAsync(new ScreenshotOptions { FullPage = true }); MemoryStream ms = new MemoryStream(); await _stream.CopyToAsync(ms); fs.StoreScreenshot(ms, $"{RecordId}.jpg"); await page.CloseAsync(); await browser.CloseAsync(); } return content; } catch (Exception ex) { log.Error($"Cannot load page, {ex.Message}"); await page.CloseAsync(); await browser.CloseAsync(); return null; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)