Hi everybody,

I am trying to scrape some Google Scholar results. I have a problem in going from the first page of result to the second, and so on. In particular, I have tried to tell follow_link to click on the link with text 'Next' but it does not seem to recognize it. I have tried to use text_regex, but no success either. I believe I am not spotting the right "text", but I really need to rely on that to look for the link because the url is very complicated. Any clue?? Many many thanks!

.

Here is the code:

my $title = Raumchemie der festen Stoffe $mech->get( "http://scholar.google.it/scholar?q=" . $title ); $mech->follow_link( url_regex => qr/cites/i, n => 1 ); my $result = $mech->content; my $indi = $mech->uri(); my $rest = $out->scrape( $result, $indi ); #~ dd( $result, $rest ); dd( $rest ); print F3 $rest; for my $i (2..200) { my $ii = $i . "0"; print "page : ".$i."\n"; $mech->follow_link( text_regex => qr/Next$/)or die("finished on page : + ".$i."\n"); my $result = $mech->content; my $indi = $mech->uri(); my $rest = $out->scrape( $result, $indi ); #~ dd( $result, $rest ); dd( $rest ); print F3 $rest; sleep(5); }

In reply to WWW::Mechanize follow_link not working by sbasbasba

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.