Advertisement
vapvarun

save google.com as html

Jan 17th, 2024
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. const puppeteer = require('puppeteer');
  2. const fs = require('fs'); // Require the Node.js 'fs' module to work with files
  3.  
  4. (async () => {
  5. // Launch a headless browser
  6. const browser = await puppeteer.launch();
  7.  
  8. // Open a new page
  9. const page = await browser.newPage();
  10.  
  11. // Navigate to Google
  12. await page.goto('https://www.google.com');
  13.  
  14. // Get the page's HTML content
  15. const html = await page.content();
  16.  
  17. // Save the HTML content to a file
  18. fs.writeFileSync('google.html', html, 'utf-8');
  19.  
  20. // Close the browser when done
  21. await browser.close();
  22. })();
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement