Ninth Prince has asked for the wisdom of the Perl Monks concerning the following question:
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:
Okay, here is the code that I have.<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>
#!/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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: WIN32::IE::Mechanize - can't follow link - JavaScript involved
by psini (Deacon) on May 22, 2008 at 16:19 UTC | |
by Ninth Prince (Acolyte) on May 22, 2008 at 17:08 UTC | |
by psini (Deacon) on May 22, 2008 at 17:33 UTC | |
by Ninth Prince (Acolyte) on May 22, 2008 at 18:10 UTC | |
by psini (Deacon) on May 22, 2008 at 18:29 UTC | |
| |
by Ninth Prince (Acolyte) on May 22, 2008 at 18:33 UTC | |
by psini (Deacon) on May 22, 2008 at 19:01 UTC | |
|