Advertisement
metalx1000

Puppeteer headless HAR dump

Jan 13th, 2024 (edited)
1,691
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mkdir hardump
  2. cd hardump
  3. npm i puppeteer-har --save
  4.  
  5. #######CODE#########
  6. const puppeteer = require('puppeteer');
  7. const PuppeteerHar = require('puppeteer-har');
  8. const url = process.argv[2];
  9. if (!url) {
  10.     throw "Please provide URL as a first argument";
  11. }
  12.  
  13. (async () => {
  14.   const browser = await puppeteer.launch({headless: 'new'});
  15.   const page = await browser.newPage();
  16.  
  17.   const har = new PuppeteerHar(page);
  18.   await har.start({ path: 'results.har' });
  19.  
  20.   await page.goto(url);
  21.  
  22.   await har.stop();
  23.   await browser.close();
  24. })();
  25.  
  26. #####RUN######
  27. node har.js "https://filmsbykris.com/"
  28. cat results.har|jq .l
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement