const puppeteer = require('puppeteer');
const fs = require('fs'); // Require the Node.js 'fs' module to work with files
(async () => {
// Launch a headless browser
const browser = await puppeteer.launch();
// Open a new page
const page = await browser.newPage();
// Navigate to Google
await page.goto('https://www.google.com');
// Get the page's HTML content
const html = await page.content();
// Save the HTML content to a file
fs.writeFileSync('google.html', html, 'utf-8');
// Close the browser when done
await browser.close();
})();
Comments