Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { chromium } = require('playwright-extra');
- const ProxyRouter = require('@extra/proxy-router');
- // Configure the proxy router plugin
- const proxyRouter = ProxyRouter({
- proxies: {
- DEFAULT: 'http://user:pass@proxyhost1:port1',
- PROXY2: 'http://user:pass@proxyhost2:port2',
- PROXY3: 'http://user:pass@proxyhost3:port3',
- // Define more proxies as needed
- },
- });
- // Add the plugin
- chromium.use(proxyRouter);
- (async () => {
- const browser = await chromium.launch({ headless: true });
- // Define target URL
- const url = 'http://httpbin.io/ip';
- // List of proxies to use
- const proxyNames = ['DEFAULT', 'PROXY2', 'PROXY3'];
- // Loop through each proxy
- for (const proxyName of proxyNames) {
- const page = await browser.newPage();
- // Use the current proxy for the page
- await page.routeByProxy(proxyName);
- // Navigate to the target page
- await page.goto(url, { waitUntil: 'domcontentloaded' });
- // Get the text content of the page
- const textContent = await page.evaluate(() => document.body.textContent);
- console.log('IP:');
- console.log(textContent);
- // Close the page for the next iteration
- await page.close();
- }
- await browser.close();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement