我正在使用puppeteer来自动化网站,puppeteer会话可能需要大约30到60秒,并且我想在该请求完成之前立即发出一个请求(打开另一个puppeteer会话),我意识到我可以不要使用setInterval,因为在我的情况下时间不是恒定的,我该如何实现
答案 0 :(得分:0)
使用递归函数在完成后立即调用同一函数。
async function bot(){
const browser = await puppeteer.launch()
// other code
await browser.close()
}
async function fireMyRequest(){
await bot()
await fireMyRequest()
}