Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const puppeteer = require('puppeteer');
- (async () => {
- // launch a headless browser
- const browser = await puppeteer.launch();
- // open a new page
- const page = await browser.newPage();
- // set a custom user agent (replace it with your desired user agent)
- await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36');
- // navigate to the target URL
- await page.goto('http://httpbin.org/user-agent');
- // get the HTML text content
- const htmlContent = await page.evaluate(() => document.body.textContent);
- // print the HTML content to the console
- console.log(htmlContent);
- // close the browser
- await browser.close();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement