Add chromium-min example

This commit is contained in:
Sparticuz 2023-02-10 14:24:07 -05:00
parent 3737536c95
commit 0f1d01e4c8
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,31 @@
const puppeteer = require("puppeteer-core");
const chromium = require("@sparticuz/chromium-min");
const handler = async () => {
try {
const browser = await puppeteer.launch({
args: chromium.args,
defaultViewport: chromium.defaultViewport,
executablePath: await chromium.executablePath(
"https://github.com/Sparticuz/chromium/releases/download/v110.0.1/chromium-v110.0.1-pack.tar"
),
headless: chromium.headless,
ignoreHTTPSErrors: true,
});
const page = await browser.newPage();
await page.goto("https://www.example.com", { waitUntil: "networkidle0" });
console.log("Chromium:", await browser.version());
console.log("Page Title:", await page.title());
await page.close();
await browser.close();
} catch (error) {
throw new Error(error.message);
}
};
handler().then(() => console.log("Done"));

View File

@ -0,0 +1,17 @@
{
"name": "chromium-remote-min",
"version": "0.0.0",
"description": "This package demonstrates using @sparticuz/chromium-min",
"license": "ISC",
"author": {
"name": "Kyle McNally"
},
"main": "index.js",
"scripts": {
"test": "node index.js"
},
"dependencies": {
"@sparticuz/chromium-min": "110.0.1",
"puppeteer-core": "19.6.3"
}
}