[英]How to run background job in node js
大家好,我已经将 res 发布到我的服务器,然后再次请求,我希望在不影响其他请求的情况下在后台运行 puppeteer 我该怎么做
module.exports = async function main(req, res) {
const url = req.body.url;
const lengths = req.body.length;
const username = req.body.username;
const password = req.body.password;
const browser = await puppeteer.launch({
res.send('wait a second');
const page = await browser.newPage();
const pages = await browser.pages();
if (pages.length > 1) {
await pages[0].close();
}
await page.goto('https://www.facebook.com', {
waitUntil: 'load',
});
await page.type('#email', username);
await page.type('#pass', password);
await page.keyboard.press('Enter');
await page.waitForTimeout(3000);
await page.goto(url, {
waitUntil: 'load',
});
await autoScroll(page, (length = lengths));
console.log('scroll done');
await takedata(page, (length = lengths)).then(async function (result) {
})
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.