7 use Data::Dump qw/dump/;
17 # Bib-1 @and @and @and @and @and @and @and @or
23 # @attr 1=21 subject-holding
24 # @attr 1=12 control-no
25 # @attr 1=1007 standard-id
28 # LCC - Klasifikacija Kongresne knjižnice
29 # LCN - Signatura Kongresne knjižnice
30 # DDC - Deweyjeva klasifikacija
35 # SRS - Nakladnička cjelina
38 # WTI - Riječi u polju naslova
39 # WAU - Riječi u polju autora
40 # WPE - Riječi u polju individualnog autora
41 # WCO - Riječi u polju korporativnog autora
42 # WME - Riječi u polju sastanka
43 # WUT - Riječi u polju jedinstvenog naslova
44 # WPL - Riječi u polju mjesta izdavanja
45 # WPU - Riječi u polju nakladnika
46 # WSU - Riječi u polju predmetnica
47 # WSM - Riječi u predmetnicama MeSH-a
48 # WST - Riječi u polju status
49 # WGA - Riječi u geografskim odrednicama
50 # WYR - Godina izdavanja
64 my ( $self, $query ) = @_;
66 die "need query" unless defined $query;
68 my $url = 'http://161.53.240.197:8991/F?RN=' . rand(1000000000);
69 # fake JavaScript code on page which creates random session
73 my $mech = $self->{mech} || die "no mech?";
76 diag "advanced search";
78 $mech->follow_link( url_regex => qr/find-c/ );
80 diag "submit search $query";
89 if ( $mech->content =~ m{ukupno\s+(\d+).*do\s+(\d+)}s ) {
91 $hits = $2 if $2 && $2 < $1; # correct for max. results
93 diag "get't find results in ", $mech->content;
97 diag "got $hits results, get first one";
99 $mech->follow_link( url_regex => qr/set_entry=000001/ );
101 diag "in MARC format";
103 $mech->follow_link( url_regex => qr/format=001/ );
110 my ($self,$format) = @_;
112 my $mech = $self->{mech} || die "no mech?";
114 print $mech->content;
116 if ( $mech->content =~ m{Zapis\s+(\d+)}s ) {
122 my $marc = MARC::Record->new;
124 my $html = $mech->content;
129 $v =~ s/\Q \E/ /gs;
132 my ($i1,$i2) = (' ',' ');
133 ($i1,$i2) = ($2,$3) if $f =~ s/^(...)(.)?(.)?/$1/;
134 my @sf = split(/\|/, $v);
136 @sf = map { s/^(\w)\s+//; { $1 => $_ } } @sf;
137 diag "sf = ", dump(@sf);
138 $marc->add_fields( $f, $i1, $i2, @sf ) if $f =~ m/^\d+$/;
141 $html =~ s|<tr>\s*<td class=td1 id=bold[^>]*>(.+?)</td>\s*<td class=td1>(.+?)</td>|field($1,$2)|ges;
144 my $id = $hash->{SYS} || die "no SYS";
146 my $path = "marc/$id.$format";
148 open(my $out, '>:utf8', $path);
149 print $out $marc->as_usmarc;
152 diag "created $path ", -s $path, " bytes";
154 # diag $marc->as_formatted;
158 die if $nr == 3; # FIXME
160 $mech->follow_link( url_regex => qr/set_entry=0*$nr/ );
162 return $marc->as_usmarc;
164 die "can't fetch COMARC format from ", $mech->content;