use WWW::Mechanize;
use MARC::Record;
-use File::Slurp;
binmode STDOUT, ':utf8';
my $comarc;
- if ( $mech->content =~ m{<pre>\s*(.+?(\d+\.)\s+ID=(\d+).+?)\s*</pre>}s ) {
+ if ( $mech->content =~ m{<pre>\s*(.+?(\d+)\.\s+ID=(\d+).+?)\s*</pre>}s ) {
my $comarc = $1;
my $nr = $2;
$comarc =~ s{<font[^>]*>}{<s>}gs;
$comarc =~ s{</font>}{<e>}gs;
- write_file "comarc/$id", $comarc;
+ open(my $out, '>:utf8', "comarc/$id");
+ print $out $comarc;
+ close($out);
print $comarc;
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;