gildas-lormeau / single-file-cli

CLI tool for saving a faithful copy of a complete web page in a single HTML file (based on SingleFile)
GNU Affero General Public License v3.0
540 stars 58 forks source link

How can I use docker cli instead of curl with cookie.json? #25

Closed pJahad closed 1 year ago

pJahad commented 1 year ago

There is a website I can download html using curl only with -H 'cookie: ghost-members-ssr=example; ghost-members-ssr.sig=example'.

For single-file-cli, I prepare the json file echo '{"ghost-members-ssr": "example", "ghost-members-ssr.sig":"example"}' > cookie.json and mount this file into docker.

However, when I run the cli with option --browser-cookie-file="/usr/src/app/node_modules/single-file-cli/cookie.json" , the result html file is not changed from without the option.

How can I use docker cli instead of curl with cookie.json?

gildas-lormeau commented 1 year ago

The format of your JSON file is incorrect, it should be something similar to this:

[{
  "domain": "example.com",
  "path": "/",
  "secure": true,
  "expires": 1680616626397,
  "name": "ghost-members-ssr",
  "value": "example",
  "httpOnly": true
},{
  "domain": "example.com",
  "path": "/",
  "secure": true,
  "expires": 1680616626397,
  "name": "ghost-members-ssr.si",
  "value": "example",
  "httpOnly": true
}]
pJahad commented 1 year ago

I tried re-creating the json, but it still failed. Is there a way to debug whether the authentication is working correctly?

gildas-lormeau commented 1 year ago

You can launch the CLI tool directly (without Docker) with --browser-debug. Then, you should be able to see the cookies in the developer tools.

pJahad commented 1 year ago

I typo'd browser-cookie-file and it was correctly browser-cookies-file. I was able to confirm that it works correctly with docker as well as CLI. Thanks for your kind support.

gildas-lormeau commented 1 year ago

You're welcome!