i want to store puppeteer page into session to use in another middleware in express
here is my code in first middleware:
(async () => {
let solve;
const browser = await puppeteer.launch({
headless: false
});
const page = await browser.newPage();
await page.setDefaultNavigationTimeout(0)
await page.goto(URL, { waitUntil: 'domcontentloaded' });
await page.click('button.imeiInquiry');
const images = await page.$eval(('.captcha-image[src]'),node => node.src);
res.send({
type: 'img',
url: images,
});
req.session.page = page;
})();
and here is the code in 2nd middleware:
(async () => {
const page = await req.session.page;
res.send(await req.session.page.title);
await page.type('#CaptchaInputText', req.body.capchaNumber);
await page.type('#ImeiNumber', req.body.imei);
await page.click('.swal2-confirm')
})
but 2nd middleware doesnt work
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment