sindresorhus / capture-website-cli

Capture screenshots of websites from the command-line
MIT License
821 stars 42 forks source link

How to use the --cookie parameter? // Error: Protocol error (Network.setCookies): Invalid parameters cookies.0.expires: double value expected #21

Closed ewasser closed 4 years ago

ewasser commented 4 years ago

Hello *,

how can I use the --cookie parameter? The examples section says --cookie="id=unicorn; Expires=Wed, 21 Oct 2018 07:28:00 GMT;".

Putting this into a CLI command will not work. Here's an example:

$ ~/node_modules/capture-website-cli/cli.js https://www.google.de --cookie="CONSENT=YES+DE.en+V9; Expires=Sat, 09 Jan 2038 07:28:00 GMT;" --output=test.png
^CError: Protocol error (Network.setCookies): Invalid parameters cookies.0.expires: double value expected
    at Promise (/home/knipser/node_modules/capture-website-cli/node_modules/puppeteer/lib/Connection.js:183:56)
    at new Promise (<anonymous>)
    at CDPSession.send (/home/knipser/node_modules/capture-website-cli/node_modules/puppeteer/lib/Connection.js:182:12)
    at Page.setCookie (/home/knipser/node_modules/capture-website-cli/node_modules/puppeteer/lib/Page.js:416:26)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  -- ASYNC --
    at Page.<anonymous> (/home/knipser/node_modules/capture-website-cli/node_modules/puppeteer/lib/helper.js:111:15)
    at captureWebsite (/home/knipser/node_modules/capture-website-cli/node_modules/capture-website/index.js:213:14)
    at process._tickCallback (internal/process/next_tick.js:68:7)

After the CLI was entered the process hangs until I press CTRL-c (you can see the ^C in the output) and then the error messages appears.

Shouldn't the --cookie parameter be parsed so the underlying library got some dictionary instead of a simple string? In the cli.js the parameter will be just arrifyed.

sindresorhus commented 4 years ago

This is fixed now: https://github.com/sindresorhus/capture-website/releases/tag/v0.8.1

Just reinstall the CLI to get the fix.

ewasser commented 4 years ago

That was awesome and fast. And it's working. Thank you!