简体   繁体   中英

403 forbidden error raised while Initializing BrowserFetcher in PuppeteerSharp

I am trying to use the PuppeteerSharp headless browser in my project and it doesn't even initialize.

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();

When it reached to the await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision); this exeption is raised:

The remote server returned an error: (403) Forbidden

You might not be able to access to https://storage.googleapis.com/chromium-browser-snapshots/Win_x64/674921/chrome-win.zip .
If you can't access to that URL, you can try to download a Chromium 77 (or greater) manually, and use the ExecutablePath property to set the Chromium app location.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM