📅  最后修改于: 2022-03-11 15:01:56.493000             🧑  作者: Mango
if (!Object.keys(cookies).length) {await page.goto("https://www.facebook.com/login", { waitUntil: "networkidle2" });await page.type("#email", config.username, { delay: 30 })await page.type("#pass", config.password, { delay: 30 })await page.click("#loginbutton");await page.waitForNavigation({ waitUntil: "networkidle0" });await page.waitFor(15000);try {await page.waitFor('[data-click="profile_icon"]');} catch (err) {console.log("failed to login");process.exit(0);}let currentCookies = await page.cookies();fs.writeFileSync('./cookies.json', JSON.stringify(currentCookies));} else{//User Already Logged In}