Interacting with the Wayback Machine

- 1 min
import requests
def get_saved_url(orig_url):
    headers = {"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 "
                                 "(KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5"}
    wburl = "https://archive.org/wayback/available?url="+orig_url
    response = requests.get(wburl,headers=headers,verify=False)
    data = response.json()
    if data['archived_snapshots']:
        saved_url = data['archived_snapshots']['closest']['url']
    else:
        saved_url = None
    return saved_url
def save_url(orig_url):
    s=requests.Session()
    savePage='https://web.archive.org/save/'
    s.get(savePage+orig_url)
comments powered by Disqus
rss facebook twitter github gitlab youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora