如何保持帐户会话登录?

时间:2020-03-15 17:26:10

标签: node.js puppeteer

我打开chrome并登录到roblox,当我运行nodejs文件时,它不会加载我的会话,我登录到roblox,这就像隐身并且我没有登录正常打开Chrome时进入我所在的站点。 注意:我没有使用无头模式

代码:

const puppeteer = require('puppeteer');

(async () => {
    const browser = await puppeteer.launch({executablePath: 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe', headless: false});
    const page = await browser.newPage();
    await page.goto('https://www.example.com/home');
    await page.screenshot({path: 'example.png'});

    await browser.close();
})();

1 个答案:

答案 0 :(得分:2)

因此,我进行了更多研究,发现可以添加GetXmlReader并为其指定路径

代码:

const puppeteer = require('puppeteer');

(async () => {
    const browser = await puppeteer.launch({executablePath: 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe', headless: false, userDataDir: "C:\\Users\\InsertUserNameHere\\AppData\\Local\\Google\\Chrome\\User Data"});
    const page = await browser.newPage();
    await page.goto('https://www.example.com/home');
    await page.screenshot({path: 'example.png'});
    await browser.close();
})();