03-13-2024, 11:25 PM
The following code can be executed successfully in LinqPad, but cannot open the webpage in LA
/*/ nuget Pts\PuppeteerSharp; /*/
using PuppeteerSharp;
Environment.CurrentDirectory = @"C:\Users\Administrator\Desktop";
static async void DoScreenshot(string url)
{
using var browserFetcher = new BrowserFetcher();
await browserFetcher.DownloadAsync();
await using var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
Headless = false,
UserDataDir = @$"{folders.Temp}\chrome\UserData"
});
await using var page = await browser.NewPageAsync();
await page.SetViewportAsync(new ViewPortOptions
{
Width = 1920,
Height = 1080
});
await page.GoToAsync(url);
await page.ScreenshotAsync("test.jpg");
await browser.CloseAsync();
}
DoScreenshot("https://www.libreautomate.com/");