125 |
|
|
126 |
diag "parse $nr"; |
diag "parse $nr"; |
127 |
|
|
128 |
|
my $marc = MARC::Record->new; |
129 |
|
|
130 |
my $html = $mech->content; |
my $html = $mech->content; |
131 |
my $hash; |
my $hash; |
132 |
$html =~ s|<tr>\s*<td class=td1 id=bold[^>]*>(.+?)</td>\s*<td class=td1>(.+?)</td>|$hash->{$1} = "$2";|ges; |
|
133 |
|
sub field { |
134 |
|
my ( $f, $v ) = @_; |
135 |
|
$v =~ s/\Q \E/ /gs; |
136 |
|
warn "# $f\t$v\n"; |
137 |
|
$hash->{$f} = $v; |
138 |
|
my ($i1,$i2) = (' ',' '); |
139 |
|
($i1,$i2) = ($2,$3) if $f =~ s/^(...)(.)?(.)?/$1/; |
140 |
|
my @sf = split(/\|/, $v); |
141 |
|
shift @sf; |
142 |
|
@sf = map { s/^(\w)\s+//; { $1 => $_ } } @sf; |
143 |
|
diag "sf = ", dump(@sf); |
144 |
|
$marc->add_fields( $f, $i1, $i2, @sf ) if $f =~ m/^\d+$/; |
145 |
|
} |
146 |
|
|
147 |
|
$html =~ s|<tr>\s*<td class=td1 id=bold[^>]*>(.+?)</td>\s*<td class=td1>(.+?)</td>|field($1,$2)|ges; |
148 |
diag dump($hash); |
diag dump($hash); |
149 |
|
|
150 |
my $id = $hash->{SYS} || die "no SYS"; |
my $id = $hash->{SYS} || die "no SYS"; |
151 |
|
|
|
die; |
|
|
|
|
|
my $marc = MARC::Record->new; |
|
152 |
|
|
|
# $marc->add_fields( $f, $i1, $i2, @{ $out->{$f} } ); |
|
153 |
|
|
154 |
my $path = "marc/$id.$format"; |
my $path = "marc/$id.$format"; |
155 |
|
|