die on unsupported format
[Biblio-Z3950.git] / Scraper.pm
index 8920978..d5e1ba8 100644 (file)
@@ -6,9 +6,13 @@ use strict;
 use WWW::Mechanize;
 
 sub new {
-    my ( $class ) = @_;
+    my ( $class, $database ) = @_;
+
+       $database ||= $class;
+
     my $self = {
                mech => WWW::Mechanize->new(),
+               database => $database,
        };
     bless $self, $class;
     return $self;
@@ -17,7 +21,7 @@ sub new {
 sub save_marc {
        my ( $self, $id, $marc ) = @_;
 
-       my $database = ref $self;
+       my $database = $self->{database};
        mkdir 'marc' unless -e 'marc';
        mkdir "marc/$database" unless -e "marc/$database";
 
@@ -31,4 +35,15 @@ sub save_marc {
 
 }
 
+our $dump_nr = 1;
+
+sub save_content {
+       my $self = shift;
+       my $path = "/tmp/$dump_nr.html";
+       open(my $html, '>', $path);
+       print $html $self->{mech}->content;
+       close($html);
+       warn "# save_content $path ", -s $path, " bytes";
+}
+
 1;