From 62915784f08e91ecb387907c0b8276f6bf15048d Mon Sep 17 00:00:00 2001 From: dpavlin Date: Sat, 20 Jun 2009 22:09:33 +0000 Subject: [PATCH] support multiple results git-svn-id: svn+ssh://llin.lib/home/dpavlin/private/svn/Z3950-HTML-Scraper@8 ae73d1a6-5fa4-44a9-8f13-f281fb455051 --- COBISS.pm | 10 +++++++--- server.pl | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/COBISS.pm b/COBISS.pm index d7628b5..f3c698d 100644 --- a/COBISS.pm +++ b/COBISS.pm @@ -5,7 +5,6 @@ use strict; use WWW::Mechanize; use MARC::Record; -use File::Slurp; binmode STDOUT, ':utf8'; @@ -119,7 +118,7 @@ sub fetch_marc { my $comarc; - if ( $mech->content =~ m{
\s*(.+?(\d+\.)\s+ID=(\d+).+?)\s*
}s ) { + if ( $mech->content =~ m{
\s*(.+?(\d+)\.\s+ID=(\d+).+?)\s*
}s ) { my $comarc = $1; my $nr = $2; @@ -131,7 +130,9 @@ diag "fetch_marc $nr [$id]"; $comarc =~ s{]*>}{}gs; $comarc =~ s{}{}gs; - write_file "comarc/$id", $comarc; + open(my $out, '>:utf8', "comarc/$id"); + print $out $comarc; + close($out); print $comarc; @@ -158,6 +159,9 @@ diag "fetch_marc $nr [$id]"; diag $marc->as_formatted; + $nr++; + $mech->follow_link( url_regex => qr/rec=$nr/ ); + return $marc->as_usmarc; } else { die "can't fetch COMARC format from ", $mech->content; diff --git a/server.pl b/server.pl index 0cfce93..6d26b06 100755 --- a/server.pl +++ b/server.pl @@ -49,7 +49,8 @@ diag "search for $query"; $this->{ERR_CODE} = 108; return; } - my $hits = $CROBISS::hits || diag "no results for $query"; + my $hits = $COBISS::hits || diag "no results for $query"; +diag "got $hits hits"; my $rs = { lower => 1, upper => $hits < $max_records ? $max_records : $hits, -- 2.20.1