Typescript - Astral

Introducció

Astral

Terminal window
deno init astral
cd astral
deno add add jsr:@astral/astral
screenshot.ts
// Import Astral
import { launch } from "@astral/astral"
// Launch the browser
await using browser = await launch();
// Open a new page
await using page = await browser.newPage("https://deno.land");
// Take a screenshot of the page and save that to disk
const screenshot = await page.screenshot();
Deno.writeFileSync("screenshot.png", screenshot);
// Clean up is performed automatically
Terminal window
deno run --allow-all .\screenshot.ts