conditional-get
CLI tool for fetching data using HTTP conditional get.
Installation
pip install conditional-get
Usage
The first time you run this command it will download the file and store the ETag (if one was returned) in a file called etags.json.
The second time you run this command against the same URL it will use that ETag, potentially resulting in a 304 Not Modified response which saves bandwidth by not re-downloading the file.
# First run - will fetch the file
conditional-get https://static.simonwillison.net/static/2020/Simon_Willison__TIL.png
# Second run - will only fetch the file if it has changed
conditional-get https://static.simonwillison.net/static/2020/Simon_Willison__TIL.png
The filename will be derived from the URL. You can customize the filename using the -o option:
conditional-get https://static.simonwillison.net/static/2020/Simon_Willison__TIL.png -o til.png
By default the ETags for the retrieved URLs will be stored in a etags.json file in the current directory. You can use the --etags otherfile.json to store that file somewhere else:
conditional-get https://static.simonwillison.net/static/2020/Simon_Willison__TIL.png --etags my-etags.json
Use the -v option to get debug output showing what is happening:
$ conditional-get https://static.simonwillison.net/static/2020/Simon_Willison__TIL.png -v
Response status code: 200
[####################################] 100%
$ ls
Simon_Willison__TIL.png etags.json
$ cat etags.json
{
"https://static.simonwillison.net/static/2020/Simon_Willison__TIL.png": "\"d65b78782dfa93213c99099e0e2181d8\""
}
$ conditional-get https://static.simonwillison.net/static/2020/Simon_Willison__TIL.png -v
Existing ETag: "d65b78782dfa93213c99099e0e2181d8"
Response status code: 304
The key used to store the ETag in etags.json defaults to the URL. You can specify a custom key using the --key option:
conditional-get --key til https://static.simonwillison.net/static/2020/Simon_Willison__TIL.png
cat etags.json
{
"til": "\"d65b78782dfa93213c99099e0e2181d8\""
}
This is useful if the URL to the file changes even though the file contents stays the same - for example if you are downloading files from URLs that include an expiring signature.
Metadata
Release files for conditional-get 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| conditional-get-0.3.tar.gz | 7.5 kB | Without provenance | Details for conditional-get-0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| conditional_get-0.3-py3-none-any.whl | Python 3 | none | any | Details for conditional_get-0.3-py3-none-any.whl |
Total release size: 15.5 kB
Release files / conditional-get-0.3.tar.gz
| Download URL | conditional-get-0.3.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
38b4a19dfbf04228834d654e3fd5ad5bd92f114ec0c3deea149e666eacfaa6cb
|
|
BLAKE2b-256 checksum How to use checksums |
d1433ff0ec880af60467a7090e1898994377ac8c4642b9c5f4fa20571e713528
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5
|
Release files / conditional_get-0.3-py3-none-any.whl
| Download URL | conditional_get-0.3-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
beb6a10ee1c691445a05c7f454b2ecb91b0b9cbd6d44d0b821070e514d3c0479
|
|
BLAKE2b-256 checksum How to use checksums |
b1d6d8498f008d828390f3a09c4fca48a32b66d2e44d373b89a9c0857a72fa7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5
|
Security for conditional-get 0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.