put the function in your .zshrc or .bashrc and then
~ ia-save http://twitter.com/atomotic
https://web.archive.org/web/20140702123925/http://twitter.com/atomotic
function ia-save() { curl -s -I https://web.archive.org/save/$* | grep Content-Location | awk '{print "https://web.archive.org"$2}' } |
I'm trying to make this a bash alias. If I add it as-is, it says "unexpected end of file" when I reload my .bashrc.
If I add a semicolon, as hugovk suggests, the .bashrc file works, but when I go to archive a page, I get the following:
awk: cmd. line:1: {print
awk: cmd. line:1: ^ unexpected newline or end of string
Any ideas? I've been playing around with the quotes (switching between " and '), but with no success.
I asked on StackOverflow and the following works for me:
function ia-save() {
curl -s -I "https://web.archive.org/save/$1" |
grep Content-Location |
awk '{printf( "https://web.archive.org/%s\n",$2)}';
}
You don't need grep
.
function ia-save() {
curl -s -I "https://web.archive.org/save/$1" |
awk '/^Content-Location/ {print "https://web.archive.org/" $2}';
}
Hey! You all are doing something that seems to have broken for me. The web.archive.org/save/
is no longer returning a Content-Location
for me in an application where it used to work.
Anyone else having this issue since July 10?
Here's a link to a related ticket: berkmancenter/amber_wordpress#59
seems that GET https://web.archive.org/save/___
is not working anymore, there is a POST
now. i will look later
Thanks!
I tried just looking at dev tools when using the website version of /save/
and it seems like the POST
request is super simple, just url=$url
.
When I run that request through PHP (WordPress HTTP API) it seems to work based on the content that's returned, but there's still no Content-Location
header.
Let me know if you find something different 🙏🏻
This one did it for me:
function ia-save() {
curl -s -I "https://web.archive.org/save/$1" | \
egrep '^location:' | \
awk '{ print $2 }';
}
Seems to me that GET request from curl still works in getting the site to perform an archive if there aren't any. I'm not sure if a new archive will be generated depending on how recent the last archive is, if it exists.
Also the header is renamed location
instead of Content-Location
.
What were you trying to curl?