last;
}
- if ( $mech->content =~ m{Please wait while your request is processed} ) {
- warn "WARNING: processing request";
+ if ( $mech->content !~ m{Please wait while your request is processed} ) {
+ warn "WARNING: expecting processing request";
}
return $years;
}
+
+our $page = 1;
+sub next_page {
+ $page++;
+ warn "next_page $page\n";
+
+ $mech->submit_form(
+ form_name => 'summary_navigation',
+ fields => {
+ 'page' => $page,
+ },
+ );
+
+ save_mech;
+
+ $mech->form_name( 'summary_navigation' );
+ my $is_next_page = $mech->value('page') == $page;
+ warn "no next_page" unless $is_next_page;
+ return $is_next_page;
+}
+
if ( $results ) {
search;
years;
}
+
+
if ( $q =~ m{CA=(.+)} && $cited_reference ) {
my $CA = $1;
while (1) {
save_mech "/tmp/isi.$q.citedref.$page";
- $page++;
-
- $mech->submit_form(
- form_name => 'summary_navigation',
- fields => {
- 'page' => $page,
- },
- );
-
- $mech->form_name( 'summary_navigation' );
- last if $mech->value('page') < $page;
+ last unless next_page();
if ( $mech->content =~ m/(\d+\s*-\s*(\d+))/ ) {
warn "span: $1\n";
my $orig_q = $q;
my $nr = 0;
+ do {
+
foreach my $link ( $mech->find_all_links( url_regex => qr/CitingArticles.do/ ) ) {
$nr++;
warn "link $nr\n";
$q = $orig_q . '.citing_article.' . $nr;
get_results;
$mech->back;
- save_mech;
$mech->back;
- save_mech;
+
+ #last if $nr > 3; # FIXME only for development
}
+ } while next_page;
+
$q = $orig_q;
}