I don't code for a living, but I do code to collect data from the web. Relatively new to PERL.

Problem. I want to fill out a form and then submit it so that I can scrape the resulting screen. My basic issue is that while I can get the relevant data into the form, I can't then get the form submitted. There is JavaScript involved on the page I'm dealing with and I'll have to admit that I don't know much about JS (if anything).

Here is the relevant HTML:

<form name="Search2" method="Post" onSubmit="return JSubmitForm();"> <tr> <td colspan="5"> <table border="0" cellPadding="3" cellSpacing="0" widt +h="100%"> <tbody> <tr> <td width="30%" class="BoldTD" colspan="2">Firm +IARD/CRD Number:</td> <td colspan="3"> <input type="text" name="CrdNumber" value="" s +ize="16" maxlength="12"> <a HREF="JavaScript:JSubmitForm()" onMouseOver +="status='Perform Search'; return true" onMouseOut="status='';"> <img SRC="/IAPD/Images/go_off.gif" alt="Go" +name="go2" onMouseover="JImgAct('go2')" onMouseout="JImgInact('go2')" + BORDER="0" align="top"> </a> </td> </tr> </tbody> </table> </td> </tr> </form>
Okay, here is the code that I have.
#!/usr/bin/perl -w use strict ; use WIN32::IE::Mechanize ; use URI ; my $agent = Win32::IE::Mechanize->new( visible => 1 ); my $url = URI->new( 'http://www.adviserinfo.sec.gov/IAPD/Content/Searc +h/iapd_OrgSearch.aspx' ) ; $agent->get($url) ; $agent->form_name("Search2") ; $agent->field("CrdNumber", "144549") ; $agent->click_button(name => "go2" ) ; my $ie = $agent->follow_link(text => "JavaScript:JSubmitForm()" ) ; exit ;

Originally I thought I had to "click" the "go2" button, but that didn't work. An earlier thread (that I read) suggested to me that what I thought was a button wasn't a button at all, but rather, a link. So, that is why I've also tried following the link. Neither works.

What can I do to get this form submitted? Thanks.

In reply to WIN32::IE::Mechanize - can't follow link - JavaScript involved by Ninth Prince

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.