-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-ia-metadata.pl
50 lines (32 loc) · 985 Bytes
/
get-ia-metadata.pl
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
44
45
46
47
48
49
50
#!C:/Perl/bin/perl -w
use strict;
use IO::File;
use utf8;
use LWP 5.64;
#Open file for output
my $meta_file = IO::File->new('ia-metadata.xml', 'w')
or die "unable to open output file for writing: $!";
binmode($meta_file, ':utf8');
my $browser = LWP::UserAgent->new;
$browser->timeout(10);
$browser->env_proxy;
$meta_file -> print('<records>');
while (<>)
{
chomp;
my $id=$_;
my $url = 'http://www.archive.org/download/'.$id.'/'.$id.'_meta.xml' ;
my $response = $browser->get( $url );
print "Can't get $url -- ", $response->status_line
unless $response->is_success;
my $meta = $response->content;
$meta =~s/\<\?xml version="1\.0" encoding="UTF-8"\?\>//;
$meta_file -> print($meta);
}
$meta_file -> print('</records>');
$meta_file->close();
=pod
use: get-ia-metadata.pl identifiers.txt
Takes a text file of Internet Archive book ids and writes the xml metadata to a file.
[email protected] 11/5/2018
=cut