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 = 50; |
my $range_size = 500; |
8 |
|
|
9 |
my $dump = @ARGV ? 1 : 0; |
my $dump = @ARGV ? 1 : 0; |
10 |
|
|
11 |
$q = 'AD=Croatia'; |
$q = 'TS=psychology AND AD=Croatia'; |
|
$range_size = 500; |
|
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 |
); |
); |
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 $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 ( $from ) { |
} # while |
97 |
|
|
98 |
my $to = $from + $range_size; |
} |
|
|
|
|
$mech->submit_form( |
|
|
form_name => 'summary_output_form', |
|
|
fields => { |
|
|
record_select_type => 'range', |
|
|
mark_from => $from, |
|
|
mark_to => $to, |
|
|
mark_id => 'WOS', |
|
|
|
|
|
qo_fields => 'fullrecord', |
|
|
citedref => 'citedref', |
|
|
|
|
|
save_options => 'plain_text', |
|
|
|
|
|
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 |
|
|
|
} |
|