const Puppeteer = require('puppeteer'); (async () => { // init const browser = await Puppeteer.launch({ headless: false, timeout: 0, defaultViewport: { width: 1920, height: 1080 } }) // login const page = await browser.newPage(); const tab = await page.goto('https://git.caner.top/pulls') const isLogin = tab.url().includes('/user/login') if (isLogin) { console.log('需要登录') await page.type('input', '5658514@qq.com', { delay: 100 }); await page.type('input[type="password"]', 'dongdong88', { delay: 100 }); await page.click('button'); await page.waitForNavigation({ timeout: 0 }); } const page2 = await browser.newPage(); await page2.goto('https://git.caner.top/pulls') console.log(123,page2.title()); })()