Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const puppeteer = require('puppeteer');
- (async () => {
- const browser = await puppeteer.launch();
- const page = await browser.newPage();
- // set custom headers to mimic a real browser
- await page.setExtraHTTPHeaders({
- 'referer': 'www.google.com',
- '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',
- 'accept-language': 'en-US,en;q=0.9',
- 'cookie': 'prov=4568ad3a-2c02-1686-b062-b26204fd5a6a; usr=p=%5b10%7c15%5d%5b160%7c%3bNewest%3b%5d',
- });
- // navigate to the target URL
- await page.goto('http://httpbin.org/headers');
- // get the HTML text content of the page
- const htmlContent = await page.evaluate(() => document.body.textContent);
- // print the HTML text content to the console
- console.log(htmlContent);
- // close the browser
- await browser.close();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement