download full results from ISI
[webpac2] / bin / isi-download-results.pl
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 my $q = 'TS=psychology AND AD=Croatia';
7
8 use WWW::Mechanize;
9 use Data::Dump qw/dump/;
10 use File::Slurp;
11
12 my $mech = WWW::Mechanize->new(
13         autocheck => 1,
14         cookie_jar => undef,
15 );
16
17 my $step = 1;
18
19 sub save_mech {
20         my $mech = shift;
21         my $path = "/tmp/isi.$step.html";
22         write_file $path, $mech->content;
23         warn "# step $step ", -s $path;
24         $mech->dump_all;
25         $step++;
26 }
27
28 warn "# get session";
29 $mech->get( 'http://isiknowledge.com/?DestApp=WOS' );
30 save_mech $mech;
31
32 warn "# advanced serach";
33 $mech->follow_link( url_regex => qr/AdvancedSearch/ );
34 save_mech $mech;
35
36 warn "# cookie_jar ", dump $mech->cookie_jar;
37
38 $mech->submit_form(
39         fields => {
40                 'value(input1)' => $q,
41         }
42 );
43 save_mech $mech;
44
45 warn "# summary";
46 $mech->follow_link( url_regex => qr/summary/ );
47 save_mech $mech;
48
49 my $from = 1;
50 my $range_size = 10;
51
52 $mech->submit_form(
53         form_name => 'summary_output_form',
54         fields => {
55                 record_select_type => 'range',
56                 mark_from => $from,
57                 mark_to => $from += $range_size,
58                 mark_id => 'WOS',
59
60                 qo_fields => 'fullrecord',
61                 citedref => 'citedref',
62
63                 save_options => 'plain_text',
64
65                 fields => 'Full',
66                 format => 'save',
67         },
68         button => 'save',
69 );
70 save_mech $mech;
71
72 warn "# save_file";
73 $mech->follow_link( url_regex => qr/save_file/ );
74 save_mech $mech;
75