screenshot with pupeteer
This commit is contained in:
parent
3defe0bf15
commit
7fa3b34b08
37
helpers/screenshot.mjs
Normal file
37
helpers/screenshot.mjs
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* prendre un screenshot avec puppeteer
|
||||
*/
|
||||
|
||||
import fs from "fs";
|
||||
|
||||
import puppeteer from "puppeteer";
|
||||
|
||||
let url = "https://www.cipherbliss.com"
|
||||
|
||||
async function captureScreenshot() {
|
||||
const targetUrl = url;
|
||||
const screenshotPath = "screenshots/github-profile.jpeg";
|
||||
|
||||
try {
|
||||
// Launch headless Chromium browser
|
||||
const browser = await puppeteer.launch({ headless: true });
|
||||
|
||||
// Create a new page
|
||||
const page = await browser.newPage();
|
||||
|
||||
// Set viewport width and height
|
||||
await page.setViewport({ width: 1440, height: 1080 });
|
||||
|
||||
// Navigate to the target URL
|
||||
await page.goto(targetUrl);
|
||||
|
||||
// Capture screenshot and save it
|
||||
await page.screenshot({ path: screenshotPath });
|
||||
await browser.close();
|
||||
console.log("\n🎉 GitHub profile screenshot captured successfully.");
|
||||
} catch (err) {
|
||||
console.log("❌ Error: ", err.message);
|
||||
}
|
||||
}
|
||||
|
||||
captureScreenshot();
|
0
helpers/screenshots/.gitkeep
Normal file
0
helpers/screenshots/.gitkeep
Normal file
Loading…
Reference in New Issue
Block a user