Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protocol error (Network.setCookies): Invalid parameters Failed to deserialize params.cookies.expires - BINDINGS: double value expected #1026

Open
Paulmicha opened this issue Nov 17, 2021 · 0 comments
Labels

Comments

@Paulmicha
Copy link

Here's what I do to write the cookies from puppeteer after successful login :

const cookies = await page.cookies();
fs.writeFileSync('path/to/cookies.json', JSON.stringify(cookies, null, 2));

Here's a working code to use the same cookies in subsequent puppeteer crawls (see source) :

await page.setCookie(...JSON.parse(fs.readFileSync('path/to/cookies.json')));

Here's how I attempt to encode it in the format expected by Phantomas (resulting in the error Failed to deserialize params.cookies.expires - BINDINGS: double value expected) :

const options = {};
const cookiesRaw = JSON.parse(fs.readFileSync('path/to/cookies.json').toString());

options.cookie = cookiesRaw.map(cookie => {
  let outputParts = [];
  Object.keys(cookie).forEach(key => outputParts.push(key + '=' + cookie[key]));
  return outputParts.join(';');
}).join('|');

Which looks like :

name=GOQPR;value=eyJ0...(snip)...%3D;domain=www.test.com;path=/;expires=-1;size=2953;httpOnly=true;secure=false;session=true;sameSite=Strict
  • Is there anything I am doing wrong ?
  • Is there another way to load this cookie into Phantomas (via YellowLabTools) ?
@macbre macbre added the bug label Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants