Skip to content

Instantly share code, notes, and snippets.

@mxbees
Last active August 20, 2016 17:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mxbees/10027420ad56c5530b5b77461dce582e to your computer and use it in GitHub Desktop.
Save mxbees/10027420ad56c5530b5b77461dce582e to your computer and use it in GitHub Desktop.
A script for saving a webpage to the Internet Archive and then bookmarking that page in Pinboard.
#!/bin/bash
#script requires a pinboard account
#also the '.pinboardcfg' is where i store my $api_token and $generic_oauth
. ~/.my-config/.pinboardcfg
auth_token='?auth_token='
base_url="https://api.pinboard.in/v1"
wget_cmd="wget -q -O -"
add_bookmark () {
url=$1
title=$2
tags="newsbeuter:archive"
description=$3
$wget_cmd "$base_url/posts/add$auth_token$api_token&format=json&url=$url&description=$title&extended=$description&tags=$tags&dt=$date&replace=$replace&shared=$share&toread=$toread"
}
#got this function from https://gist.github.com/atomotic/721aefe8c72ac095cb6e
ia_save() {
curl -s -I https://web.archive.org/save/$1 | grep Content-Location | awk '{print "https://web.archive.org"$2}'
}
ia_page=$(ia_save "$1")
add_bookmark "$ia_page" "$2" "$3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment