Skip to main content

A simple Python wrapper for's "Save Page Now" capturing service

Project description

A simple Python wrapper for’s “Save Page Now” capturing service

PyPI version


$ pipenv install savepagenow

Python Usage

Import it.

>>> import savepagenow

Capture a URL.

>>> archive_url = savepagenow.capture("")

See where it’s stored.

>>> print(archive_url)

If a URL has been recently cached, may return the URL to that page rather than conduct a new capture. When that happens, the capture method will raise a CachedPage exception.

This is likely happen if you request the same URL twice within a few seconds.

>>> savepagenow.capture("")
>>> savepagenow.capture("")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "savepagenow/", line 36, in capture
savepagenow.exceptions.CachedPage: returned a cached version of this page:

You can craft your code to catch that exception yourself, or use the built-in capture_or_cache method, which will return the URL provided by along with a boolean indicating if it is a fresh capture (True) or from the cache (False).

>>> savepagenow.capture_or_cache("")
('', True)
>>> savepagenow.capture_or_cache("")
('', False)

There’s no accounting for taste but you could craft a line to handle that command like so:

>>> url, captured = savepagenow.capture_or_cache("")

Command-line usage

The Python library is also installed as a command-line interface. You can run it from your terminal like so:

$ savepagenow

The command has the same options as the Python API, which you can learn about from its help output.

$ savepagenow --help
Usage: savepagenow [OPTIONS] URL

  Archives the provided URL using the Wayback Machine.

  Raises a CachedPage exception if declines to conduct a new
  capture and returns a previous snapshot instead.

  -ua, --user-agent TEXT  User-Agent header for the web request
  -c, --accept-cache      Accept and return cached URL
  --help                  Show this message and exit.

Customizing the user agent

In an effort to be transparent and polite to the Internet Archive, all requests made by savepagenow carry a custom user agent that identifies itself as "savepagenow (".

You can further customize this setting by using the optional arguments to our API.

Here’s how to do it in Python:

>>> savepagenow.capture("", user_agent="my user agent here")

And here’s how to do it from the command line:

$ savepagenow --user-agent "my user agent here"

Developing the CLI

The command-line interface is implemented using Click and setuptools. To install it locally for development inside your virtual environment, run the following installation command, as [prescribed by the Click documentation](

$ pip install --editable .

Project details

Download files

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

Source Distribution

savepagenow-1.1.1.tar.gz (5.7 kB view hashes)

Uploaded source

Built Distribution

savepagenow-1.1.1-py2.py3-none-any.whl (6.4 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page