/[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 1281 by dpavlin, Fri Sep 18 17:28:03 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/;
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  );  );
# Line 21  sub save_mech { Line 26  sub save_mech {
26          $path ||= sprintf('/tmp/isi.%02d.%s', $step, $mech->{ct} =~ m{html}i ? 'html' : 'txt' );          $path ||= sprintf('/tmp/isi.%02d.%s', $step, $mech->{ct} =~ m{html}i ? 'html' : 'txt' );
27          $mech->save_content( $path );          $mech->save_content( $path );
28          warn "# [$step] $path ", -s $path, " ", $mech->ct;          warn "# [$step] $path ", -s $path, " ", $mech->ct;
29          $mech->dump_all;          $mech->dump_all if $dump;
30  }  }
31    
32  warn "# get session";  warn "# get session";
# Line 45  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 = 50;          my $q = shift;
55            my $from = 1;
56  while ( $from ) {  
57            while ( 1 ) {
58          my $to = $from + $range_size;  
59                    my $to = $from + $range_size;
60          $mech->submit_form(  
61                  form_name => 'summary_output_form',                  $mech->submit_form(
62                  fields => {                          form_name => 'summary_output_form',
63                          record_select_type => 'range',                          fields => {
64                          mark_from => $from,                                  record_select_type => 'range',
65                          mark_to => $to,                                  mark_from => $from,
66                          mark_id => 'WOS',                                  mark_to => $to,
67                                    mark_id => 'WOS',
68                          qo_fields => 'fullrecord',  
69                          citedref => 'citedref',                                  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                          save_options => 'plain_text',          } # while
97    
98                          fields => 'Full',  }
                         format => 'save',  
                 },  
                 button => 'save',  
         );  
         save_mech $mech;  
99    
100          last if $mech->content =~ m{invalid API call};  get_results $q;
101    
102          warn "# save_file";  save_mech $mech;
103          $mech->follow_link( url_regex => qr/save_file/ );  warn "# citations";
104          save_mech $mech => "/tmp/isi.$q.$from-$to.txt";  $mech->follow_link( url_regex => qr/search_mode=CitationReport/ );
105    save_mech $mech;
106    
107          $from += $range_size;  $mech->follow_link( url_regex => qr/search_mode=TotalCitingArticles/ );
108    save_mech $mech;
109    
110          $mech->back;  get_results $q . '.citing';
         $mech->back;  
         #save_mech $mech;  
111    
 }  

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

  ViewVC Help
Powered by ViewVC 1.1.26