1 |
dpavlin |
70 |
package Meteor::Koha; |
2 |
|
|
|
3 |
|
|
use strict; |
4 |
|
|
use warnings; |
5 |
|
|
|
6 |
|
|
use LWP::UserAgent; |
7 |
|
|
|
8 |
|
|
my $ua = LWP::UserAgent->new; |
9 |
|
|
|
10 |
|
|
sub item { |
11 |
|
|
my ( $class, $client, $item ) = @_; |
12 |
|
|
|
13 |
|
|
my $url = 'http://koha.ffzg.hr/cgi-bin/koha/opac-detail.pl?biblionumber=' . $item; |
14 |
|
|
|
15 |
|
|
my $response = $ua->get( $url ); |
16 |
|
|
|
17 |
|
|
my $html = $response->content; |
18 |
|
|
$html =~ s{<head>.+?<h1>}{<h1>}s; |
19 |
|
|
$html =~ s{<div class="content_set">.+$}{}s; |
20 |
|
|
|
21 |
|
|
my $len = length($html); |
22 |
|
|
|
23 |
|
|
warn "# koha item $item [$len]\n"; |
24 |
|
|
|
25 |
|
|
$client->write( |
26 |
|
|
'HTTP/1.1 ' . $response->status_line . "\r\n" . |
27 |
|
|
"Content-Type: text/html\r\n" . |
28 |
|
|
"Content-length: $len\r\n" . |
29 |
|
|
"Connection: close\r\n" . |
30 |
|
|
"\r\n\r\n$html\r\n" |
31 |
|
|
); |
32 |
|
|
|
33 |
|
|
} |
34 |
|
|
|
35 |
|
|
1; |