Skip to content

Instantly share code, notes, and snippets.

@eeskildsen
Last active March 9, 2020 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eeskildsen/b4d4b31551d555482319dd8c9f9608e3 to your computer and use it in GitHub Desktop.
Save eeskildsen/b4d4b31551d555482319dd8c9f9608e3 to your computer and use it in GitHub Desktop.
using PuppeteerSharp;
using System.Linq;
using System.Threading.Tasks;
namespace PuppeteerBoilerplate
{
class Program
{
static async Task Main(string[] args)
{
var browserFetcherOptions = new BrowserFetcherOptions
{
Path = @"C:\my\puppeteer\folder",
};
RevisionInfo revisionInfo = await new BrowserFetcher(browserFetcherOptions).DownloadAsync(BrowserFetcher.DefaultRevision);
var launchOptions = new LaunchOptions
{
Headless = true,
ExecutablePath = revisionInfo.ExecutablePath,
};
using (var browser = await Puppeteer.LaunchAsync(launchOptions))
using (var page = (await browser.PagesAsync()).First())
{
await page.GoToAsync("https://www.example.com");
// Do stuff...
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment