Last active
March 9, 2020 20:08
-
-
Save eeskildsen/b4d4b31551d555482319dd8c9f9608e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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