Skip to content

Instantly share code, notes, and snippets.

@wcaleb
Last active December 29, 2020 06:55
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save wcaleb/218d210687546c8efd0a to your computer and use it in GitHub Desktop.
Save wcaleb/218d210687546c8efd0a to your computer and use it in GitHub Desktop.
Quick script to save URL to Wayback Machine
#! /usr/bin/env python
import sys, requests
# Usage: Pass URL to script, get back URL to Wayback Machine snapshot
base_url = 'http://web.archive.org'
r = requests.get(base_url + '/save/' + sys.argv[1])
if r.status_code == requests.codes.ok:
print base_url + r.headers['content-location']
else:
print 'Error in response: ' + str(r.status_code)
# or you could just return the original url
# print sys.argv[1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment