/[webpac2]/trunk/bin/isi-download-results.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/bin/isi-download-results.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1280 by dpavlin, Fri Sep 18 16:52:57 2009 UTC revision 1289 by dpavlin, Sat Sep 19 10:23:35 2009 UTC
# Line 3  Line 3 
3  use warnings;  use warnings;
4  use strict;  use strict;
5    
6  my $q = 'TS=psychology AND AD=Croatia';  my $q = 'AD=Croatia';
7    my $range_size = 500;
8    
9    my $dump = @ARGV ? 1 : 0;
10    
11    $q = 'TS=psychology AND AD=Croatia';
12    
13  use WWW::Mechanize;  use WWW::Mechanize;
14  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
 use File::Slurp;  
15    
16  my $mech = WWW::Mechanize->new(  our $mech = WWW::Mechanize->new(
17          autocheck => 1,          autocheck => 1,
18          cookie_jar => undef,          cookie_jar => undef,
19  );  );
20    
21  my $step = 1;  our $step = 0;
22    
23  sub save_mech {  sub save_mech {
24          my $mech = shift;          my ( $mech, $path ) = @_;
         my $path = "/tmp/isi.$step.html";  
         write_file $path, $mech->content;  
         warn "# step $step ", -s $path;  
         $mech->dump_all;  
25          $step++;          $step++;
26            $path ||= sprintf('/tmp/isi.%02d.%s', $step, $mech->{ct} =~ m{html}i ? 'html' : 'txt' );
27            $mech->save_content( $path );
28            warn "# [$step] $path ", -s $path, " ", $mech->ct;
29            $mech->dump_all if $dump;
30  }  }
31    
32  warn "# get session";  warn "# get session";
# Line 46  warn "# summary"; Line 50  warn "# summary";
50  $mech->follow_link( url_regex => qr/summary/ );  $mech->follow_link( url_regex => qr/summary/ );
51  save_mech $mech;  save_mech $mech;
52    
53  my $from = 1;  sub get_results {
54  my $range_size = 10;          my $q = shift;
55            my $from = 1;
56    
57            while ( 1 ) {
58    
59                    my $to = $from + $range_size;
60    
61                    $mech->submit_form(
62                            form_name => 'summary_output_form',
63                            fields => {
64                                    record_select_type => 'range',
65                                    mark_from => $from,
66                                    mark_to => $to,
67                                    mark_id => 'WOS',
68    
69                                    qo_fields => 'fullrecord',
70                                    citedref => 'citedref',
71    
72                                    save_options => 'plain_text',
73    
74                                    fields => 'Full',
75                                    format => 'save',
76                            },
77                            button => 'save',
78                    );
79                    save_mech $mech;
80    
81                    if ( $mech->content =~ m{invalid API call} ) {
82                            $mech->back;
83                            return;
84                    }
85    
86                    warn "# save_file $from - $to [$q]";
87                    $mech->follow_link( url_regex => qr/save_file/ );
88                    save_mech $mech => "/tmp/isi.$q.$from-$to.txt";
89    
90                    $from += $range_size;
91    
92                    $mech->back;
93                    $mech->back;
94                    #save_mech $mech;
95    
96            } # while
97    
98    }
99    
100    get_results $q;
101    
102  $mech->submit_form(  save_mech $mech;
103          form_name => 'summary_output_form',  warn "# citations";
104          fields => {  $mech->follow_link( url_regex => qr/search_mode=CitationReport/ );
                 record_select_type => 'range',  
                 mark_from => $from,  
                 mark_to => $from += $range_size,  
                 mark_id => 'WOS',  
   
                 qo_fields => 'fullrecord',  
                 citedref => 'citedref',  
   
                 save_options => 'plain_text',  
   
                 fields => 'Full',  
                 format => 'save',  
         },  
         button => 'save',  
 );  
105  save_mech $mech;  save_mech $mech;
106    
107  warn "# save_file";  $mech->follow_link( url_regex => qr/search_mode=TotalCitingArticles/ );
 $mech->follow_link( url_regex => qr/save_file/ );  
108  save_mech $mech;  save_mech $mech;
109    
110    get_results $q . '.citing';
111    

Legend:
Removed from v.1280  
changed lines
  Added in v.1289

  ViewVC Help
Powered by ViewVC 1.1.26