1
1
mirror of https://github.com/namibia/awesome-cheatsheets.git synced 2024-12-19 08:49:45 +00:00

feat(puppeteer): add puppeeter and browserfetcher

This commit is contained in:
Julien Le Coupanec 2020-03-17 13:14:24 +01:00
parent 0a88f6209f
commit c882af50b7

View File

@ -40,15 +40,15 @@ PUPPETEER_PRODUCT // Specify which browser you'd like Puppeteer t
const puppeteer = require('puppeteer'); const puppeteer = require('puppeteer');
puppeteer.devices; puppeteer.devices; // Returns a list of devices to be used with page.emulate(options)
puppeteer.errors; puppeteer.errors; // Returns the specific error classes
puppeteer.product; puppeteer.product; // Returns the name of the browser that is under automation ("chrome" or "firefox")
puppeteer.connect(options); puppeteer.connect(options); // Attaches Puppeteer to an existing Chromium instance.
puppeteer.createBrowserFetcher([options]); puppeteer.createBrowserFetcher([options]); // Create a brower fetcher instance
puppeteer.defaultArgs([options]); puppeteer.defaultArgs([options]); // The default flags that Chromium will be launched with.
puppeteer.executablePath(); puppeteer.executablePath(); // Returns a path where Puppeteer expects to find bundled Chromium.
puppeteer.launch([options]); puppeteer.launch([options]); // Launch a browser instance
// BROWSER FETCHER // BROWSER FETCHER
// BrowserFetcher can download and manage different versions of Chromium. // BrowserFetcher can download and manage different versions of Chromium.
@ -56,12 +56,12 @@ puppeteer.launch([options]);
const browserFetcher = puppeteer.createBrowserFetcher(); const browserFetcher = puppeteer.createBrowserFetcher();
browserFetcher.canDownload(revision) browserFetcher.canDownload(revision) // Initiates a HEAD request to check if the revision is available.
browserFetcher.download(revision[, progressCallback]) browserFetcher.download(revision[, progressCallback]) // Initiates a GET request to download the revision from the host.
browserFetcher.localRevisions() browserFetcher.localRevisions() // Returns a list of all revisions available locally on disk.
browserFetcher.platform() browserFetcher.platform() // Returns one of mac, linux, win32 or win64.
browserFetcher.remove(revision) browserFetcher.remove(revision) // Resolves when the revision has been removed.
browserFetcher.revisionInfo(revision) browserFetcher.revisionInfo(revision) // Returns all the information on the revision.
// BROWSER // BROWSER
// A Browser is created when Puppeteer connects to a Chromium instance, either through puppeteer.launch or puppeteer.connect. // A Browser is created when Puppeteer connects to a Chromium instance, either through puppeteer.launch or puppeteer.connect.
@ -69,10 +69,10 @@ browserFetcher.revisionInfo(revision)
const browser = await puppeteer.launch(); const browser = await puppeteer.launch();
browser.on('disconnected') browser.on('disconnected') //
browser.on('targetchanged') browser.on('targetchanged') //
browser.on('targetcreated') browser.on('targetcreated') //
browser.on('targetdestroyed') browser.on('targetdestroyed') //
browser.browserContexts() browser.browserContexts()
browser.close() browser.close()