Gangmax Blog

SingleFile CLI Again

The SingleFile CLI can be used to download the target web page into a single file with one command line. One of my previous post shows how to run it in Docker, while this post shows how to run it locally.

Basic Usage

First, you should download the execution file from here. Be sure to select the correct one for your “OS/Arch”. For example, if you’re using Mac with silicon chip(ARM arch), you should select “single-file-aarch64-apple-darwin”. In this post I will use “Linux/x86/_64” in the command samples.

Before running, make sure Chrome or a Chromium-based browser is installed and can be found in default “PATH”. Otherwise you may need to set the “–browser-executable-path” option in the command line when executing “single-file”.

After you add the execution permission to the downloaded file, you can try running it.

1
2
3
# Basic usage: single-file [url] [output] <option*>
# Runing without any arguments/options will print all the available options.
./single-file-x86_64-linux https://imtx.me/ index.html

Advanced Usage

Sometimes the target web page needs login to view the content. In this case we need to save the “cookies” of the website from your browser, then use the “cookies” in the “single-file” running to make it work.

Save the cookies

You need to install some extension in your browser to save the target cookies. For example, in Chrome you can install the “Cookie-Editor“ extension.

Open the target web page(login if it’s required), then open the “Cookie-Editor” extension, select “Export -> JSON”, the cookies of this website for you will be saved into a local JSON file. Let’s say it’s “cookies.json”.

Run

Now you can download the target web page with the cookie file like below.

1
2
./single-file-x86_64-linux --browser-cookies-file='cookies.json' \
https://articles.zsxq.com/id_9getlhtuixe5.html venezeula.html

Be careful with your cookie file especially not share it with anybody else, because that means anyone which has this cookie file can do all operations as you can do on the target website, just like he/she can login the website with your account.

Comments