vapvarun icon

save google.com as html

vapvarun | PRO | 01/17/24 11:48:20 AM UTC | 0 ⭐ | 608 👁️ | Never ⏰ | []
text |

580 B

|

None

|

0 👍

/

0 👎

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