I am trying to run this code with multiple address ips but I think I put the proxy code in the wrong place can someone help, the proxy dashboard shows that the code uses the proxy but when he opened the browser the address IP doesn't change is still my local IP.the code need to run multiple browsers each browser with a unique different IP.
const puppeteer = require("puppeteer-extra");
const StealthPlugin = require("puppeteer-extra-plugin-stealth");
puppeteer.use(StealthPlugin());
const { Cluster } = require("puppeteer-cluster");
const util = require('util');
const fs = require('fs');
const readFile = util.promisify(fs.readFile);
const langBtns = require('./langBtns');
async function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
let choices = Object.values(langBtns);
let randObj;
let buttons;
let lang;
let button;
let goodBtnSelector;
let cluster;
const start = async () => {
cluster = await Cluster.launch({
concurrency: Cluster.CONCURRENCY_CONTEXT,
maxConcurrency: 4, // provide the puppeteer-core library
puppeteer,
puppeteerOptions: {
headless: false,
executablePath:
"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
slowMo: 10,
defaultViewport: null,
args: [
"--no-sandbox",
"--disable-setuid-sandbox",
"--disable-dev-shm-usage",
"--disable-accelerated-2d-canvas",
"--no-first-run",
"--no-zygote",
"--disable-gpu",
"--disable-notifications",
"--proxy-server=megaproxy.rotating.proxyrack.net:1200"
],
},
// and provide executable path (in this case for a Chrome installation in Ubuntu)
});
await cluster.task(async ({ page, data: lang}) => {
await Promise.all([
await visitWebsite(page, lang),
]);
});
//add number of bots, here 5
for (let index = 0; index < 1000000; index++) {
//Choosing an object (lang+buttons) from the JSON file
randObj = choices[Math.floor(Math.random()*choices.length)];
//Storing the buttons of the choosing language in the array buttons
buttons = randObj.buttons;
button = buttons[Math.floor(Math.random()*buttons.length)];
lang = randObj.language;
goodBtnSelector = randObj.goodButtonSelector;
}
await cluster.idle();
await cluster.close();
};
const visitWebsite = async (page, lang) => {
await cluster.queue(lang);
// add proxy credentials
await page.authenticate({
username: 'XXXXXXXX',
password: 'XXXXXXXXXXX'
});
console.log(lang);
try{
await page.goto(`https://whatismyipaddress.com/`, {
waitUntil: "load",
timeout: 60000
});
await sleep(200 + Math.floor(Math.random() * 50));
let scriptFilePath = 'search.js';
let testScript = (await readFile(`${scriptFilePath}`));
await Promise.all([
eval('(async () => {' + testScript.toString() + '})')()
]);
}catch (e) {
console.log(e.toString());
}
};
start();