Advertisement
dereksir

Untitled

Dec 26th, 2023 (edited)
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const puppeteer = require('puppeteer');
  2.  
  3. (async () => {
  4.   const browser = await puppeteer.launch();
  5.   const page = await browser.newPage();
  6.  
  7.   // set custom headers to mimic a real browser
  8.   await page.setExtraHTTPHeaders({
  9.     'referer': 'www.google.com',
  10.     'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
  11.     'accept-language': 'en-US,en;q=0.9',
  12.     'cookie': 'prov=4568ad3a-2c02-1686-b062-b26204fd5a6a; usr=p=%5b10%7c15%5d%5b160%7c%3bNewest%3b%5d',
  13.   });
  14.  
  15.   // navigate to the target URL
  16.   await page.goto('http://httpbin.org/headers');
  17.  
  18.   // get the HTML text content of the page
  19.   const htmlContent = await page.evaluate(() => document.body.textContent);
  20.  
  21.   // print the HTML text content to the console
  22.   console.log(htmlContent);
  23.  
  24.   // close the browser
  25.   await browser.close();
  26. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement