use warnings;
use strict;
-use WWW::Mechanize;
use MARC::Record;
use Data::Dump qw/dump/;
-binmode STDOUT, ':utf8';
+use base 'Scraper';
our $mech = WWW::Mechanize->new();
our $hits;
# WGA - Riječi u geografskim odrednicama
# WYR - Godina izdavanja
-our $usemap = {
-# 8 => '',
-# 7 => '',
+sub usemap {{
4 => 'WTI',
1003 => 'WTI',
16 => 'CU',
};
-sub usemap {
- my $f = shift || die;
- $usemap->{$f};
-}
sub search {
my ( $self, $query ) = @_;
diag "get $url";
+ my $mech = $self->{mech} || die "no mech?";
$mech->get( $url );
diag "advanced search";
diag "in MARC format";
$mech->follow_link( url_regex => qr/format=001/ );
+
+ return $hits;
}
sub next_marc {
my ($self,$format) = @_;
+ my $mech = $self->{mech} || die "no mech?";
+
print $mech->content;
if ( $mech->content =~ m{Zapis\s+(\d+)}s ) {
use warnings;
use strict;
-use WWW::Mechanize;
use MARC::Record;
use Data::Dump qw/dump/;
-binmode STDOUT, ':utf8';
-
-sub new {
- my ( $class ) = @_;
- my $self = {};
- bless $self, $class;
- return $self;
-}
-
+use base 'Scraper';
my $cobiss_marc21 = {
'010' => { a => [ '020', 'a' ] },
diag "get $url";
- my $mech = $self->{mech} = WWW::Mechanize->new();
+ my $mech = $self->{mech} || die "no mech?";
+
my $hits;
$mech->get( $url );
--- /dev/null
+package Scraper;
+
+use warnings;
+use strict;
+
+use WWW::Mechanize;
+
+binmode STDOUT, ':utf8';
+
+sub new {
+ my ( $class ) = @_;
+ my $self = {
+ mech => WWW::Mechanize->new(),
+ };
+ bless $self, $class;
+ return $self;
+}
+