perBrowserOptions - Proxy Question?
See original GitHub issueHi,
I am trying to create an application that will run multiple instances of puppeteer, each instance will have its own proxy. The new “perBrowserOptions” is good but how can I set the proxy based on the Taskfunction that has been queued when using “CONCURRENCY_BROWSER”?
Here is an example to try and explain what i mean…
`const {Cluster} = require(‘puppeteer-cluster’);
(async ()=>{
const proxies = [];
//Create the cluster
const cluster = await Cluster.launch({
concurrency: Cluster.CONCURRENCY_BROWSER,
maxConcurrency: 4,
// puppeteerOptions : {
// headless : false,
// args : [
// '--no-sandbox',
// '--disable-setuid-sandbox',
// '--disable-infobars',
// '--window-position=0,0',
// '--ignore-certifcate-errors',
// '--ignore-certifcate-errors-spki-list',
// `--proxy-server=${proxies.shift()}`
// ]
// },
//Something like this would be nice
browserLaunchedOption:()=>{
//return options for browser
return {
headless : false,
args : [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-infobars',
'--window-position=0,0',
'--ignore-certifcate-errors',
'--ignore-certifcate-errors-spki-list',
`--proxy-server=${proxies.shift()}`
]
}
}
});
const loginFBWithProxyTask = async ({page,data})=> {
proxies.push(data.proxy.ip);
//Somehow need to set the proxy here... from data.proxy.ip
//Proxy must match account
await page.authenticate({
username: data.proxy.user,
password: data.proxy.pass
});
await page.goto("http://facebook.com", {waitUntil: "domcontentloaded"});
//await page.type()
//perform login etc....
};
//check DB every 30 sec
setInterval(function () {
//fetch some accounts from a db
const accounts = [ //returned from db just for example
{
fb_username : "Joe Blogs",
fb_password : "pass",
proxy : {
ip : "51.91.195.74:29842",
user : "proxyuser",
pass : "password"
}
},
{
fb_username : "Jame Smith",
fb_password : "pass",
proxy : {
ip : "21.21.195.24:29842",
user : "myproxyuser",
pass : "myproxypass"
}
},
{
fb_username : "Mary Poppins",
fb_password : "pass",
proxy : {
ip : "21.21.295.24:29842",
user : "myproxyuser",
pass : "myproxypass"
}
}];
//QUEUE UP Tasks to perform perBrowser
for (const account in accounts) {
cluster.queue(account,loginFBWithProxyTask);
}
},30000);
})();`
I just can’t work out how i can set the proxy per browser launch to match the account that is fetched/queued…
Hope some of that made sense, thanks!
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Help in the use of puppeteer-cluster #277 - GitHub
Hello, I'm practicing with headless browser and I plan to make a little viewerbot. The goal would be to be able to put...
Read more >I can't use a rotating IP proxy in my puppeteer cluster script
I am trying to run this code with multiple address ips but I think I put the proxy code in the wrong place...
Read more >Creating a new browser profile and attaching a proxy in ...
In this video we show you how to create your first browser profile in Incogniton. The only thing you need to do is...
Read more >puppeteer-cluster - bytemeta
How use proxy? · Help in the use of puppeteer-cluster · Make a live viewer bot - Questions · No error thrown on...
Read more >Puppeteer Proxy Integration With Oxylabs
Proxy integration with Puppeteer, a Node.js library, is simple. Find out how to integrate Oxylabs' Residential Proxies in this easy-to-understand tutorial.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Im not sure, would something like
cluster.queueWithBrowserOptions(data,taskFunction,browserOptions)
work?Or add another prop to
cluster.queue(data,taskFunction,browserOptions)
then if “CONCURRENCY_BROWSER” is used, “pupeteerOptions” can be defined for each task in the queue.Thanks
+1