7 use Data::Dump qw/dump/;
12 my $debug = $ENV{DEBUG} || 0;
20 # Bib-1 @and @and @and @and @and @and @and @or
26 # @attr 1=21 subject-holding
27 # @attr 1=12 control-no
28 # @attr 1=1007 standard-id
44 my ( $self, $query ) = @_;
46 die "need query" unless defined $query;
48 # http://catalog.hathitrust.org/Search/Home?lookfor=croatia%20AND%20zagreb&type=title
49 my $url = 'http://catalog.hathitrust.org/Search/Home?lookfor=' . $query;
53 $self->mech->get( $url );
57 if ( $self->mech->content =~ m{of\s*<span class="strong">(\d+)</span>\s*Results for}s ) {
60 diag "get't find results in ", $self->mech->content;
64 diag "got $hits results";
66 foreach my $link ( $self->mech->find_all_links( url_regex => qr{/Record/\d+} ) ) {
67 push @{ $self->{records} }, $link->url;
70 return $self->{hits} = $hits;
75 my ($self,$format) = @_;
79 my $url = shift @{ $self->{records} };
81 my $id = $1 if $url =~ m{Record/(\d+)};
83 $self->mech->get( $url . '.mrc' );
85 $self->save_marc( "$id.marc", $self->mech->content );