Answer the question
In order to leave comments, you need to log in
How to set your own proxy for each page?
Explain to the unknowing how to connect each page to a different proxy.
I tried to use puppeteer-page-proxy, when connecting, the browser just fell off with the "Target closed" error.
Googled and dug up that you can use Proxy-Chain, but how? I created a separate server for the proxy and took the proxy validated for the given url from the list, but the browser still just crashed and gave the "Target closed" error. Whole code:
let ProxyChain = require("proxy-chain");
let { Cluster } = require("puppeteer-cluster");
(async () => {
let driver = await Cluster.launch({
concurrency: Cluster.CONCURRENCY_CONTEXT,
maxConcurrency: 2,
puppeteerOptions: {
headless: false,
},
});
await driver.task(async ({ page, data: url }) => {
let server = new ProxyChain.Server({
port: 8000,
verbose: true,
prepareRequestFunction: async ({ request }) => {
console.log(123);
return {
upstreamProxyUrl: await require("./proxy-provider")(
"proxies1.txt"
).getRandomProxy(url),
};
},
});
server.listen(() => console.log("worked"));
await page.setRequestInterception(true);
await page.goto(url);
});
driver.queue("TARGET_URL");
await driver.idle();
await driver.close();
})();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question