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
65 my ( $self, $query ) = @_;
67 die "need query" unless defined $query;
69 $session_id ||= int rand(1000000000);
70 # FIXME allocate session just once
71 my $url = 'http://161.53.240.197:8991/F?RN=' . $session_id;
72 # fake JavaScript code on page which creates random session
76 my $mech = $self->{mech} || die "no mech?";
79 diag "advanced search";
81 $mech->follow_link( url_regex => qr/find-c/ );
83 diag "submit search [$query] on ", $self->{database};
90 'local_base' => $self->{database},
95 if ( $mech->content =~ m{ukupno\s+(\d+).*do\s+(\d+)}s ) {
97 $hits = $2 if $2 && $2 < $1; # correct for max. results
99 diag "get't find results in ", $mech->content;
103 diag "got $hits results, get first one";
105 $mech->follow_link( url_regex => qr/set_entry=000001/ );
107 diag "in MARC format";
109 $mech->follow_link( url_regex => qr/format=001/ );
115 our ( $hash, $marc );
118 my ($self,$format) = @_;
122 my $mech = $self->{mech} || die "no mech?";
124 #warn "## ", $mech->content;
126 if ( $mech->content =~ m{Zapis\s+(\d+)}s ) {
132 $marc = MARC::Record->new;
135 my $html = $mech->content;
139 $v =~ s/\Q \E/ /gs;
149 warn "$f not numeric!";
153 if ( $v !~ s/^\|// ) { # no subfields
154 $marc->add_fields( $f, $v );
155 warn "## ++ ", dump( $f, $v );
159 my ($i1,$i2) = (' ',' ');
160 ($i1,$i2) = ($2,$3) if $f =~ s/^(...)(.)?(.)?/$1/;
161 my @sf = split(/\|/, $v);
162 @sf = map { s/^(\w)\s+//; { $1 => $_ } } @sf;
163 #warn "## sf = ", dump(@sf);
164 $marc->add_fields( $f, $i1, $i2, @sf );
165 warn "## ++ ", dump( $f, $i1, $i2, @sf );
168 $html =~ s|<tr>\s*<td class=td1 id=bold[^>]*>(.+?)</td>\s*<td class=td1>(.+?)</td>|field($1,$2)|ges;
169 diag "# hash ",dump($hash);
170 diag "# marc ", $marc->as_formatted;
172 my $id = $hash->{SYS} || die "no SYS";
174 $self->save_marc( $id, $marc->as_usmarc );
178 $mech->follow_link( url_regex => qr/set_entry=0*$nr/ );
180 return $marc->as_usmarc;
182 die "can't fetch COMARC format from ", $mech->content;