Dear all,

Im using WWW::Mechanize to scrape a online library of citations. It seems to be working well, and easily. However, this online library needs a session id, persistent throughout its search, which is present in a hidden input field.

Here's my code so far:

#!/usr/bin/perl -w require strict; use WWW::Mechanize; my $mech = WWW::Mechanize->new( autocheck => 1 ); $mech->get("http://isiknowledge.com/?DestApp=WOS&Func=Frame"); $mech->follow_link(tag => 'frame', n => 2); $mech->form_number(1); $mech->click('General Search', [2,2]); $mech->form_number(1); $mech->field("topic","emergence AND complexity"); $mech->click(); $mech->form_number(1); $mech->field('mark_from',1); $mech->field('mark_to',500); $mech->field('mark_selection','range'); my $res=$mech->click('Submit'); print $res->content;
Its pretty straight forward, and for the first couple of pages, it goes well, but on the last 'Submit', the response page claims I need to start a new session!! I've encountered this before, and I actually did try extracting the session id from previous pages, and inserting it into the hidden field in the last page, but WWW::Mechanize wont let me, as it says that field is 'read-only' I assume because it is hidden.

The funny thing is, I stopped using HTTP::Request::Form, because there was a bug concerning multiple checkboxes of the same name, however doing this same thing with HRF, I could get through to the next page, so WWW::Mechanize seems to be dropping the session id, what's going on?

Is it possible that there's a redirect that it's following automatically WITHOUT the session id?

Thanks
Seaver


In reply to WWW::Mechanize and session id by seaver

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.