-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-oai.pl
31 lines (27 loc) · 1.07 KB
/
test-oai.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
#! /usr/bin/perl
use XML::Simple;
use LWP::UserAgent;
use HTTP::Request::Common;
use Data::Dumper;
my $base_url="https://ebs-suu.bywatersolutions.com/cgi-bin/koha/oai.pl?verb=ListRecords";
#my $extra = "&resumptionToken=marcxml/46650////0/0/158146";
my $url = "$base_url"."&metadataPrefix=marcxml";
my $ua = LWP::UserAgent->new();
while ( $url ){
my $content = $ua->get($url, 'Accept-Encoding' => 'gzip,deflate');
warn "could not retrieve $url" unless $content;
warn "GOT URL: $url";
#warn Data::Dumper::Dumper( $content);
#warn Data::Dumper::Dumper( $content->decoded_content);
my $xmlsimple = XML::Simple->new();
my $result = $xmlsimple->XMLin($content->decoded_content);
#warn Data::Dumper::Dumper( $result );
# foreach my $header ( @{$result->{ListRecords}->{record}} ){
# warn $header->{header}->{identifier};
# }
my $token = $result->{ListRecords}->{resumptionToken}->{content};
$url = $token ?
$base_url . "&resumptionToken=".$result->{ListRecords}->{resumptionToken}->{content}
: undef ;
warn "NEXT URL: $url";
}