Answer the question
In order to leave comments, you need to log in
How to selectively close one of the open browsers in puppeteer?
It is necessary to keep a certain number of sessions enabled at the same time. For example 6. Apparently, this can only be done by opening a browser in puppeteer for each session.
Question: How can I close the browser for a specific session?
start_script()
async function start_script(){
json = [ '4444444444', '5555555555', '8888888888', '7777777777'] // Это логины для авторизации
for(let i = 0; i < json.length; i++) {
await start_chrom(json[i])
}
}
async function start_chrom(login) {
const browser = await puppeteer.launch({
headless: true,
args: [ '--no-sandbox' ]
});
const page = await browser.newPage();
await page.goto('здесь_ссылка_на_сайт.ру', {
waitUntil: 'networkidle2'
})
// здесь авторизация
await page.waitForTimeout(1000)
await page.click('#login')
await page.keyboard.sendCharacter(login)
await page.click('#button_auth')
await page.waitForTimeout(1000)
// здесь вызов основного функционала
calling_the_main_functionality(page)
return true
}
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