Advertisement
dereksir

Untitled

Aug 31st, 2023 (edited)
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //..
  2.  
  3. // Configure the proxy router plugin
  4. const proxyRouter = ProxyRouter({
  5.   proxies: {
  6.     DEFAULT: 'http://217.11.184.20:3128',
  7.     PROXY2: 'http://20.33.5.27:8888',
  8.     PROXY3: 'http://45.133.72.252:3128',
  9.     // Define more proxies as needed
  10.   },
  11. });
  12.  
  13.     //..
  14.  
  15.     // Loop through each proxy
  16.     for (const proxyName of proxyNames) {
  17.         const page = await browser.newPage();
  18.  
  19.         // Use the current proxy for the page
  20.         await page.route(url, (route) => {
  21.             route.continue({ server: proxyName });
  22.         });
  23.  
  24.         // Navigate to the target page
  25.         await page.goto(url, { waitUntil: 'domcontentloaded' });
  26.  
  27.         // Get the text content of the page
  28.         const textContent = await page.evaluate(() => document.body.textContent);
  29.  
  30.         console.log(textContent);
  31.  
  32.         // Close the page for the next iteration
  33.         await page.close();
  34.   }
  35.  
  36.     await browser.close();
  37. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement