Advertisement
dereksir

Untitled

Aug 30th, 2023 (edited)
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { firefox } = require('playwright');
  2.  
  3. (async () => {
  4.     // Launch Firefox browser in headless mode
  5.     const browser = await firefox.launch({ headless: true });
  6.     // Open a new page
  7.     const page = await browser.newPage();
  8.  
  9.     // Navigate to target URL and wait until network idle
  10.     await page.goto('https://www.example.com', { waitUntil: 'networkidle' });
  11.  
  12.     // Get the text content of the page
  13.     const textContent = await page.evaluate(() => document.body.textContent);
  14.  
  15.     console.log(textContent);
  16.     await browser.close();
  17. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement