我试图在我的项目中使用 PuppeteerSharp 无头浏览器,它甚至没有初始化。
var task = Task.Run(async () =>
{
await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
Headless = false
});
var page = await browser.NewPageAsync();
await page.SetUserAgentAsync("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36");
await page.GoToAsync("https://resanehlab.com");
html = await page.GetContentAsync();
});
task.Wait();
当它达到await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
这个异常时:
远程服务器返回错误:(403) Forbidden