savepagenow

1.3.1 · active · verified Fri Apr 17

savepagenow is a simple Python wrapper and command-line interface for archive.org’s 'Save Page Now' capturing service. It allows users to programmatically request that the Internet Archive save a specific URL. The library is currently at version 1.3.1 and maintains an active release cadence, primarily with dependency updates and important feature additions like authentication and rate limit documentation.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `savepagenow` to archive a URL. It includes an example of how to optionally pass authentication credentials, which are required for private captures. It's recommended to set `WAYBACK_ACCESS_KEY` and `WAYBACK_SECRET_KEY` environment variables for authenticated use.

import os
from savepagenow import save_page_now

# Replace with the URL you want to archive
url_to_archive = "https://example.com/"

# Optional: Set authentication credentials via environment variables or direct arguments
# If you don't set these, captures will be public (if supported by IA)
# For private captures, you'll need a Wayback Machine access key and secret.
# WAYBACK_ACCESS_KEY='YOUR_ACCESS_KEY'
# WAYBACK_SECRET_KEY='YOUR_SECRET_KEY'

# Example using environment variables (recommended)
access_key = os.environ.get('WAYBACK_ACCESS_KEY', '')
secret_key = os.environ.get('WAYBACK_SECRET_KEY', '')

try:
    if access_key and secret_key:
        print(f"Attempting to save {url_to_archive} with authentication...")
        archive = save_page_now(
            url_to_archive,
            auth_key=access_key,
            auth_secret=secret_key
        )
    else:
        print(f"Attempting to save {url_to_archive} without authentication...")
        archive = save_page_now(url_to_archive)

    if archive.get('archive_url'):
        print(f"Page saved successfully: {archive['archive_url']}")
    else:
        print(f"Failed to save page. Response: {archive}")

except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →