Created
July 3, 2020 09:46
-
-
Save jorol/6c281ec6366df03ec5f15ef2071955a0 to your computer and use it in GitHub Desktop.
Request data from SRU by ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/perl -w | |
use strict; | |
use warnings; | |
use Catmandu::Importer::SRU; | |
# specify I/O layer | |
open( my $fh, '>>:encoding(UTF-8)', 'blabla.txt' ); | |
my $exporter = Catmandu->exporter( 'PICA', type => 'PLUS', fh => $fh ); | |
# make a single request for each ID | |
while ( my $idn = <DATA> ) { | |
chomp $idn; | |
my $importer = Catmandu::Importer::SRU->new( | |
base => 'https://services.dnb.de/sru/dnb', | |
recordSchema => 'PicaPlus-xml', | |
parser => 'ppxml', | |
query => "idn=$idn", | |
); | |
$importer->each( | |
sub { | |
my $item = shift; | |
$exporter->add($item); | |
my $x = int rand(1000); | |
print "la $x\n"; | |
} | |
); | |
} | |
$exporter->commit; | |
print "end\n"; | |
__DATA__ | |
1203108583 | |
1204818975 | |
1208307592 | |
1172608431 | |
1206987235 | |
1207535087 | |
1203412339 | |
120264449X | |
1163614947 | |
1204708207 | |
1207535109 | |
1205140670 | |
120470645X | |
1208307770 | |
117365934X | |
1204819556 | |
1205969268 | |
1204818215 | |
1203107285 | |
1203108303 | |
1208142356 | |
1205369929 | |
1203107862 | |
120814183X | |
1207536253 | |
1208142054 | |
1204819084 | |
1203530439 | |
1204817995 | |
1203065744 | |
1204819505 | |
1202695213 | |
1207875619 | |
1204819173 | |
1207535125 | |
1203108214 | |
1204818363 | |
1207434876 | |
120310751X | |
1204705771 | |
120753529X | |
1204347654 | |
1204709467 | |
120269554X | |
1206855843 | |
1206492120 | |
1172716781 | |
1203108265 | |
120470791X | |
1207535931 | |
1204666571 | |
120694384X | |
1202641024 | |
120310734X | |
1208142038 | |
120753532X | |
1204818304 | |
1202695434 | |
1204709211 | |
1207535818 | |
1202694268 | |
1208242784 | |
1203368585 | |
1203065434 | |
120753577X | |
1203065566 | |
1208142011 | |
1206072822 | |
1204347808 | |
1208141643 | |
1203107617 | |
1203352581 | |
1208307681 | |
1202695272 | |
120470693X | |
1202643914 | |
1206240482 | |
1204565228 | |
1206987146 | |
1204708177 | |
1203853351 | |
1206492708 | |
1206868848 | |
1204334153 | |
1207535249 | |
1204707286 | |
1207435082 | |
1204819025 | |
120269490X | |
1202694993 | |
1204868530 | |
1205421408 | |
1207535079 | |
1203107471 | |
1204346860 | |
1207536180 | |
1207535532 | |
1207536628 | |
1173901213 | |
1203108451 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment