Network.getAllCookies
#返回所有浏览器cookie。根据后端支持,将在cookie字段中返回详细的cookie信息。
RETURN OBJECT
cookies
array Cookie
Array of cookie objects.
(async() => {
const browser = await puppeteer.launch({});
const page = await browser.newPage();
await page.goto('https://stack.com', {waitUntil : 'networkidle2' });
// tried params like this as well
// {waitUntil: 'load', timeout: 0}
// {waitUntil: 'domContentLoaded', timeout: 0}
// Here we can get all of the cookies
console.log(await page._client.send('Network.getAllCookies'));
})();
不返回所有cookie-获得站点中第三方脚本设置的cookie的任何其他功能。?
[如果您使用的是MacOS,我还很难查看所有cookie。然后,我添加了NPM包chrome-cookies-secure
并能够看到它们。 (https://www.npmjs.com/package/chrome-cookies-secure)