76 |
|
|
77 |
my $url = 'http://cobiss.izum.si/scripts/cobiss?ukaz=GETID&lani=en'; |
my $url = 'http://cobiss.izum.si/scripts/cobiss?ukaz=GETID&lani=en'; |
78 |
|
|
79 |
diag "# get $url"; |
diag "get $url"; |
80 |
|
|
81 |
$mech->get( $url ); |
$mech->get( $url ); |
82 |
|
|
83 |
diag "# got session"; |
diag "got session"; |
84 |
|
|
85 |
$mech->follow_link( text_regex => qr/union/ ); |
$mech->follow_link( text_regex => qr/union/ ); |
86 |
|
|
87 |
diag "# switch to advanced form (select)"; |
diag "switch to advanced form (select)"; |
88 |
|
|
89 |
$mech->follow_link( url_regex => qr/mode=3/ ); |
$mech->follow_link( url_regex => qr/mode=3/ ); |
90 |
|
|
91 |
diag "# submit search $query"; |
diag "submit search $query"; |
92 |
|
|
93 |
$mech->submit_form( |
$mech->submit_form( |
94 |
fields => { |
fields => { |
104 |
return; |
return; |
105 |
} |
} |
106 |
|
|
107 |
diag "# got $hits results, get first one"; |
diag "got $hits results, get first one"; |
108 |
|
|
109 |
$mech->follow_link( url_regex => qr/ukaz=DISP/ ); |
$mech->follow_link( url_regex => qr/ukaz=DISP/ ); |
110 |
|
|
111 |
diag "# in COMARC format"; |
diag "in COMARC format"; |
112 |
|
|
113 |
$mech->follow_link( url_regex => qr/fmt=13/ ); |
$mech->follow_link( url_regex => qr/fmt=13/ ); |
114 |
} |
} |
125 |
my $nr = $2; |
my $nr = $2; |
126 |
my $id = $3; |
my $id = $3; |
127 |
|
|
128 |
diag "# fetch_marc $nr [$id]"; |
diag "fetch_marc $nr [$id]"; |
129 |
|
|
130 |
$comarc =~ s{</?b>}{}gs; |
$comarc =~ s{</?b>}{}gs; |
131 |
$comarc =~ s{<font[^>]*>}{<s>}gs; |
$comarc =~ s{<font[^>]*>}{<s>}gs; |
138 |
my $marc = MARC::Record->new; |
my $marc = MARC::Record->new; |
139 |
|
|
140 |
foreach my $line ( split(/[\r\n]+/, $comarc) ) { |
foreach my $line ( split(/[\r\n]+/, $comarc) ) { |
|
our @f; |
|
141 |
|
|
142 |
if ( $line !~ s{^(\d\d\d)([01 ])([01 ])}{} ) { |
if ( $line !~ s{^(\d\d\d)([01 ])([01 ])}{} ) { |
143 |
diag "SKIP: $line"; |
diag "SKIP: $line"; |
144 |
} else { |
} else { |
145 |
$line .= "<eol>"; |
$line .= "<eol>"; |
146 |
|
|
147 |
@f = ( $1, $2, $3 ); |
our @f = ( $1, $2, $3 ); |
148 |
sub sf { push @f, @_; } |
sub sf { push @f, @_; } |
149 |
$line =~ s{<s>(\w)<e>([^<]+)\s*}{sf($1, $2)}ges; |
$line =~ s{<s>(\w)<e>([^<]+)\s*}{sf($1, $2)}ges; |
150 |
diag "# f:", join('|', @f), " left: |$line|"; |
diag "f:", join('|', @f), " left: |$line|"; |
151 |
$marc->add_fields( @f ); |
$marc->add_fields( @f ); |
152 |
} |
} |
153 |
} |
} |