Skip to main content

CLI tool for fetching data using HTTP conditional get

Project description

conditional-get

PyPI CircleCI License

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

conditional_get-0.2a0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file conditional_get-0.2a0-py3-none-any.whl.

File metadata

  • Download URL: conditional_get-0.2a0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.10

File hashes

Hashes for conditional_get-0.2a0-py3-none-any.whl
Algorithm Hash digest
SHA256 a72ab137f6eb2f215321d1990fc9615f77ca696890c697dd1dabbed36aa029d8
MD5 8aa8250375ed84b1a3bc5521e5bfec07
BLAKE2b-256 5181e5078328baa705a2b3e44321470ea4061c409edfd2fdf072f18324dd4306

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page