9 my $dump = @ARGV ? 1 : 0;
11 $q = 'TS=psychology AND AD=Croatia';
14 use Data::Dump qw/dump/;
16 our $mech = WWW::Mechanize->new(
24 my ( $mech, $path ) = @_;
26 mkdir '/tmp/isi/' unless -e '/tmp/isi';
27 my $base_path = sprintf('/tmp/isi/%04d', $step);
28 $path ||= $base_path . ( $mech->{ct} =~ m{html}i ? '.html' : '.txt' );
29 $mech->save_content( $path );
30 warn "# [$step] $path ", -s $path, " ", $mech->ct, "\n";
31 open(my $dump, '>', "$base_path.dump.txt");
32 $mech->dump_all($dump);
36 $mech->get( 'http://isiknowledge.com/?DestApp=WOS' );
42 warn "# advanced serach";
43 $mech->follow_link( url_regex => qr/AdvancedSearch/ );
46 warn "# cookie_jar ", dump $mech->cookie_jar;
50 'value(input1)' => $q,
56 $mech->follow_link( url_regex => qr/summary/ );
66 my $to = $from + $range_size;
69 form_name => 'summary_output_form',
71 record_select_type => 'range',
76 qo_fields => 'fullrecord',
77 citedref => 'citedref',
79 save_options => 'plain_text',
88 if ( $mech->content =~ m{invalid API call} ) {
93 warn "range $from - $to [$q]\n";
94 $mech->follow_link( url_regex => qr/save_file/ );
95 save_mech $mech => "/tmp/isi.$q.$from-$to.txt";
110 warn "# citation report";
111 $mech->follow_link( url_regex => qr/search_mode=CitationReport/ );
114 warn "view citing articles";
115 $mech->follow_link( url_regex => qr/search_mode=TotalCitingArticles/ );
120 my $years_url = $mech->find_link( text_regex => qr/more options/ )->url_abs;
121 warn "## $years_url";
122 $years_url =~ s{ra_name=\w+}{ra_name=PublicationYear} || die "ra_name";
123 warn "# refine years (hidden by javascript)";
124 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";
125 $mech->get( $years_url );
128 my $html = $mech->content;
130 while ( $html =~ s{>(\d\d\d\d)\s\((\d+)\)</label.+?value="PublicationYear_}{} ) {
131 push @years, [ $1 => $2 ];
133 warn "# years ",dump @years;
144 get_results $q . '.citing';