Advertisement
dereksir

Untitled

Feb 1st, 2024 (edited)
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { chromium } = require(“playwright”);
  2.  
  3. (async () => {
  4.   // Launch the Chromium browser
  5.   const browser = await chromium.launch();
  6.  
  7.   const context = await browser.newContext({
  8.     userAgent: “Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/109.0,
  9.   });
  10.  
  11.   // Create a new page in the browser context and navigate to target URL
  12.   const page = await context.newPage();
  13.   await page.goto(“https://httpbin.io/user-agent”);
  14.  
  15.   // Get the entire page content
  16.   const pageContent = await page.content();
  17.   console.log(pageContent);
  18.  
  19.   // Close the browser
  20.   await browser.close();
  21. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement