### Installation with pipenv Source: https://github.com/palewire/savepagenow/blob/main/docs/index.md Installs the savepagenow package using pipenv. ```bash pipenv install savepagenow ``` -------------------------------- ### Capture or cache example Source: https://github.com/palewire/savepagenow/blob/main/docs/index.md Demonstrates the behavior of capture_or_cache when a page is already cached. ```default savepagenow.capture("http://www.example.com/") 'https://web.archive.org/web/20161019062637/http://www.example.com/' savepagenow.capture("http://www.example.com/") Traceback ( File "", line 1, in File "savepagenow/__init__.py", line 36, in capture archive_url savepagenow.exceptions.CachedPage: archive.org returned a cached version of this page: https://web.archive.org/web/20161019062637/http://www.example.com/ ``` -------------------------------- ### Development installation Source: https://github.com/palewire/savepagenow/blob/main/docs/index.md Installs the savepagenow package in editable mode for local development. ```bash pip install --editable . ``` -------------------------------- ### Handle capture or cache result Source: https://github.com/palewire/savepagenow/blob/main/docs/index.md Example of handling the output from capture_or_cache. ```python url, captured = savepagenow.capture_or_cache("http://www.example.com/") ``` -------------------------------- ### Custom user agent from command line Source: https://github.com/palewire/savepagenow/blob/main/docs/index.md Demonstrates how to set a custom user agent when using the savepagenow command-line interface. ```bash savepagenow http://www.example.com/ --user-agent "my user agent here" ``` -------------------------------- ### Custom user agent in Python Source: https://github.com/palewire/savepagenow/blob/main/docs/index.md Demonstrates how to set a custom user agent when capturing a URL in Python. ```python savepagenow.capture("http://www.example.com/", user_agent="my user agent here") ``` -------------------------------- ### Capture or cache method usage Source: https://github.com/palewire/savepagenow/blob/main/docs/index.md Shows how to use the capture_or_cache method and interpret its return values. ```python savepagenow.capture_or_cache("http://www.example.com/") ("https://web.archive.org/web/20161019062832/http://www.example.com/", True) savepagenow.capture_or_cache("http://www.example.com/") ("https://web.archive.org/web/20161019062832/http://www.example.com/", False) ``` -------------------------------- ### Command-line usage Source: https://github.com/palewire/savepagenow/blob/main/docs/index.md Basic command-line execution of savepagenow. ```bash savepagenow https://example.com/ ``` -------------------------------- ### CLI help message Source: https://github.com/palewire/savepagenow/blob/main/docs/index.md The help message for the savepagenow command-line interface. ```bash Usage: savepagenow [OPTIONS] URL Archive the provided URL using archive.org's Wayback Machine. Raises a CachedPage exception if archive.org declines to conduct a new capture and returns a previous snapshot instead. Options: -ua, --user-agent TEXT User-Agent header for the web request -c, --accept-cache Accept and return cached URL -a, --authenticate Allows you to run saves with authentication --help Show this message and exit. ``` -------------------------------- ### Importing the library Source: https://github.com/palewire/savepagenow/blob/main/docs/index.md Imports the savepagenow library into a Python script. ```python import savepagenow ``` -------------------------------- ### Capture a URL Source: https://github.com/palewire/savepagenow/blob/main/docs/index.md Captures a given URL using the savepagenow library. ```python archive_url = savepagenow.capture("http://www.example.com/") ``` -------------------------------- ### Print captured URL Source: https://github.com/palewire/savepagenow/blob/main/docs/index.md Prints the URL of the captured page. ```python print(archive_url) ``` -------------------------------- ### Authenticated capture Source: https://github.com/palewire/savepagenow/blob/main/docs/index.md Captures a URL with authentication enabled. ```python savepagenow.capture(url, authenticate=True) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.