From e954f104fba0c6ef9142f09042e0b7e7f73d7388 Mon Sep 17 00:00:00 2001 From: Sebastian Hammer Date: Sun, 28 Jan 2007 03:43:19 +0000 Subject: [PATCH] Simple Zeerex fetcher --- zeerex/zeerex_fetchall.pl | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 zeerex/zeerex_fetchall.pl diff --git a/zeerex/zeerex_fetchall.pl b/zeerex/zeerex_fetchall.pl new file mode 100755 index 0000000..9267554 --- /dev/null +++ b/zeerex/zeerex_fetchall.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl -w + +use strict; +use ZOOM; +use XML::Simple; +use Data::Dumper; +use URI::Escape; + +if (!$ARGV[0]) +{ + die("Usage xx irspy-server\n"); +} +my $server = $ARGV[0]; + +my $c = new ZOOM::Connection($server); +my $res = $c->search(new ZOOM::Query::CQL('cql.allRecords=1')); +$res->option(schema => 'zeerex'); +print STDERR "Hits: " . $res->size() . "\n"; +my $i; +for ($i = 0; $i < $res->size(); $i++) +{ + my $rec = $res->record($i); + my $txt = $rec->raw(); + my $r = XML::Simple::XMLin($txt, forceArray => + ['set', 'index', 'map', 'attr', 'supports', 'missing', + 'recordSyntax', 'elementSet']); + my $si = $r->{serverInfo}; + if ($si->{protocol} ne 'Z39.50') + { + next; + } + $si->{host} =~ s/^ *//; + $si->{host} =~ s/ *$//; + $si->{port} =~ s/^ *//; + $si->{port} =~ s/ *$//; + $si->{database} =~ s/^ *//; + $si->{database} =~ s/ *$//; + my $id = $si->{host} . ":" . $si->{port} . "/" . $si->{database}; + $id = uri_escape($id); + print STDERR $id . "\n"; + open O, ">records/$id" or die "$id: $!"; + print O $txt; + close O; +} -- 1.7.10.4