use base 'Scraper';
sub diag {
- print "# ", @_, $/;
+ warn "# ", @_, $/;
}
# Koha Z39.50 query:
my $id = $hash->{SYS} || die "no SYS";
- my $path = "marc/$id.$format";
-
- open(my $out, '>:utf8', $path) || die "$path: $!";
- print $out $marc->as_usmarc;
- close($out);
-
- diag "created $path ", -s $path, " bytes";
-
-# diag $marc->as_formatted;
+ $self->save_marc( $id, $marc->as_usmarc );
$nr++;
- die if $nr == 3; # FIXME
-
$mech->follow_link( url_regex => qr/set_entry=0*$nr/ );
return $marc->as_usmarc;
use WWW::Mechanize;
-binmode STDOUT, ':utf8';
-
sub new {
my ( $class ) = @_;
my $self = {
return $self;
}
+sub save_marc {
+ my ( $self, $id, $marc ) = @_;
+
+ my $database = ref $self;
+ mkdir 'marc' unless -e 'marc';
+ mkdir "marc/$database" unless -e "marc/$database";
+
+ my $path = "marc/$database/$id";
+
+ open(my $out, '>:utf8', $path) || die "$path: $!";
+ print $out $marc;
+ close($out);
+
+ warn "# created $path ", -s $path, " bytes";
+
+}
+
+1;