Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Puppeteer Sharp: avoid downloading Chromium (bundle Chromium locally)

I'm using Puppeteer Sharp in my .NET application to do some webpage automation tasks. However, I have to deploy my app in an environment that only has intranet access, which means Puppeteer's BrowserFetcher class is unable to download Chromium from the internet, since it cannot access the Chromium repositories.

Is it possible to bundle a copy of Chromium with my app, so Puppeteer does not have to download it? How would I do that? I'm not finding much in the docs about this...

like image 693
Master_T Avatar asked Nov 19 '18 08:11

Master_T


1 Answers

You can use the LaunchOptions.ExecutablePath property. If you use ExecutablePath you don't even need to call BrowserFetcher. It would look something like this:

var options = new LaunchOptions
{
    Headless = true,
    ExecutablePath = "<CHROME.EXE FULL PATH>"
};

using (var browser = await Puppeteer.LaunchAsync(options))
{
}
like image 166
hardkoded Avatar answered Oct 24 '22 10:10

hardkoded