Update README.md, mention new --source argument
This commit is contained in:
parent
19e01c762d
commit
359696e5e2
31
README.md
31
README.md
|
@ -6,27 +6,44 @@ file, mirroring its remote images, stylesheets, and other resources.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
```
|
```
|
||||||
usage: mirror-img [-h] [-d DIR] [-b BASE] HTML_FILE
|
usage: mirror-img [-h] [-d DIR] [-b BASE] [-s URL] HTML_FILE
|
||||||
mirror-img [-h] [-d DIR] [-b BASE]
|
mirror-img [-h] [-d DIR] [-b BASE] [-s URL]
|
||||||
Available options:
|
Available options:
|
||||||
-h, --help print this help text.
|
-h, --help print this help text.
|
||||||
-b, --base path to mirror directory used in URLs
|
-b, --base ARG path to mirror directory used in URLs
|
||||||
|
-s, --source ARG URL used to resolve & mirror relative URLs
|
||||||
-d, --downloads ARG directory for all mirrored files
|
-d, --downloads ARG directory for all mirrored files
|
||||||
```
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
#### Remote
|
||||||
In order to mirror a webpage, you can simply download it and pipe it into mirror-img:
|
In order to mirror a webpage, you can simply download it and pipe it into mirror-img:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ curl https://www.gnu.org/philosophy/philosophy.html | mirror-img > philosophy.html
|
$ curl https://www.gnu.org/philosophy/philosophy.html | mirror-img > philosophy.html
|
||||||
```
|
```
|
||||||
|
|
||||||
And now `philosophy.html` will be a fully-local HTML file, with no external resources!
|
And now `philosophy.html` is a fully-local HTML file with no external resources!
|
||||||
All mirrored content will be found in the `mirror/` directory, and all links
|
|
||||||
have been adjusted accordingly.
|
|
||||||
|
|
||||||
|
… at least, it *would* be. Notice how some resources, like the CSS, don’t load.
|
||||||
|
This is because they are defined as *relative* links (e.g., “../style.css”
|
||||||
|
rather than “https://invalid.tld/style.css”). In order for these to be
|
||||||
|
mirrored as well, mirror-img needs to somehow know the source URL.
|
||||||
|
|
||||||
|
You can use the `--source` argument to provide the source URL, so
|
||||||
|
relatively-linked resources can be mirrored, too:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ SOURCE_URL="https://www.gnu.org/philosophy/philosophy.html"
|
||||||
|
$ curl "$SOURCE_URL" | mirror-img --source "$SOURCE_URL" > philosophy.html
|
||||||
|
```
|
||||||
|
|
||||||
|
*Now* we’re done! All mirrored content will be found in the `mirror/`
|
||||||
|
directory, and all links have been adjusted accordingly.
|
||||||
|
|
||||||
|
#### Local
|
||||||
If you’d like to change the download directory, you can use the `--downloads`
|
If you’d like to change the download directory, you can use the `--downloads`
|
||||||
argument. To change the directory used in the output HTML’s URLs, you can
|
argument. To change the directory used in the output-HTML’s URLs, you can
|
||||||
use `--base`.
|
use `--base`.
|
||||||
|
|
||||||
For example, if you’d like to mirror files into `/tmp/mirrors/` but have URLs
|
For example, if you’d like to mirror files into `/tmp/mirrors/` but have URLs
|
||||||
|
|
Ŝarĝante…
Reference in New Issue