-
Notifications
You must be signed in to change notification settings - Fork 11
/
archive-this
executable file
·43 lines (39 loc) · 974 Bytes
/
archive-this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env perl
use v5.14;
use strict;
use warnings;
use Data::Dumper;
use Hijk;
my $url = shift @ARGV or die "Usage: $0 \URL\n";;
my $archivers = [
sub {
my $res = Hijk::request({
method => "GET",
host => "archive.is",
port => "80",
path => "/submit/",
body => "url=$url",
parse_chunked => 1,
});
return $res;
},
sub {
my $res = Hijk::request({
method => "GET",
host => "web.archive.org",
port => "80",
path => "/save/$url",
parse_chunked => 1,
});
return $res;
},
];
for my $archiver (@$archivers) {
my $kid = fork();
unless ($kid) {
my $res = $archiver->();
say $res->{status}, " ", (substr( ($res->{status} =~ /^3/) ? $res->{head}{Location} : $res->{body} , 0, 64) =~ s/\n/\\n/gr);
exit;
}
}
wait() for @$archivers;