9 my $dump = @ARGV ? 1 : 0;
11 $q = 'TS=psychology AND AD=Croatia';
14 use Data::Dump qw(dump);
17 our $mech = WWW::Mechanize->new(
24 my $dir = '/tmp/isi/';
25 rmtree $dir if -e $dir;
29 my ( $mech, $path ) = @_;
31 my $base_path = sprintf('%s/%04d', $dir,$step);
32 $path ||= $base_path . ( $mech->{ct} =~ m{html}i ? '.html' : '.txt' );
33 $mech->save_content( $path );
34 warn "# [$step] $path ", -s $path, " ", $mech->ct, "\n";
35 open(my $dump, '>', "$base_path.dump.txt");
36 $mech->dump_all($dump);
40 $mech->get( 'http://isiknowledge.com/?DestApp=WOS' );
44 warn "# advanced serach";
45 $mech->follow_link( url_regex => qr/AdvancedSearch/ );
48 warn "# cookie_jar ", dump $mech->cookie_jar;
52 'value(input1)' => $q,
58 $mech->follow_link( url_regex => qr/summary/ );
67 my $to = $from + $range_size;
70 form_name => 'summary_output_form',
72 record_select_type => 'range',
77 qo_fields => 'fullrecord',
78 citedref => 'citedref',
80 save_options => 'plain_text',
89 if ( $mech->content =~ m{invalid API call} ) {
94 warn "range $from - $to [$q]\n";
95 $mech->follow_link( url_regex => qr/save_file/ );
96 save_mech $mech => "/tmp/isi.$q.$from-$to.txt";
111 warn "# citation report";
112 $mech->follow_link( url_regex => qr/search_mode=CitationReport/ );
115 warn "view citing articles";
116 $mech->follow_link( url_regex => qr/search_mode=TotalCitingArticles/ );
121 my $years_url = $mech->find_link( text_regex => qr/more options/ );
122 if ( ! $years_url ) {
123 warn "W: can't find years\n";
126 $years_url = $years_url->url_abs;
127 warn "## $years_url";
128 if ( $years_url !~ s{ra_name=\w+}{ra_name=PublicationYear} ) {
129 warn "W: no ra_name\n";
132 warn "# refine years (hidden by javascript)";
133 warn "http://apps.isiknowledge.com/RAMore.do?product=WOS&search_mode=TotalCitingArticles&SID=T1o6bChdN9PGP1LN1Nh&qid=3&ra_mode=more&ra_name=PublicationYear&db_id=WOS&viewType=raMore\n$years_url\n";
134 $mech->get( $years_url );
137 my $html = $mech->content;
139 while ( $html =~ s{>(\d\d\d\d)\s\((\d+)\)</label.+?value="PublicationYear_}{} ) {
142 warn "# years ",dump $years;