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

$ 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.1.1a0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: conditional_get-0.1.1a0-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.1.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4202c9ac6e7e1ee5cc896e637290deded6b413bc5e07dd92cd6d6c7fcf10a22
MD5 8485591a771926d1aa3e9d423f27c192
BLAKE2b-256 ccebeadca8d2aa7d43a77068a3c8bec05aabbbafc2f1292300645e48fb3a5c2e

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