Re: :Mechanize question
am 15.12.2006 03:14:54 von cajunDuzenbury, Rich wrote:
> Hello,
>
> Hmm, not sure, but I recently did a post, and I made sure to explicitly
> set the form number, and explicity click the correct submit button:
>
> print "Accessing the login page\n";
> $mech->get($loginurl);
> die "Could not access login page: ", $mech->response->status_line unless
> $mech->success;
>
> # Now, fill in the form and submit it.
> print "Logging in\n";
> $mech->form_number(1);
> $mech->field( 'txtActNumber', $login );
> $mech->field( 'txtActPass' , $password);
> $mech->field( 'radlLogin', "Download");
> $mech->click_button('name' => 'btnLogin');
> die "Could not submit login form: ", $mech->response->status_line unless
> $mech->success;
>
>
> Regards,
>
> Rich Duzenbury
> IT Department
> Brokers International, Ltd.
> 1200 E. Main
> Panora, IA 50216
> (800) 362-1097 ext 1401
>
>
>
>
>> -----Original Message-----
>> From: M. Lewis [mailto:cajun@cajuninc.com]
>> Sent: Wednesday, December 13, 2006 10:58 PM
>> To: libwww@perl.org
>> Subject: WWW::Mechanize question
>>
>>
>> I've used WWW::Mechanize before, but not for posting to a
>> form on the web. I'm trying to automate some very boring
>> postings of spammers to the rfci website. I'm not having much
>> luck with it.
>>
>> mech-dump tells me:
>>
>> [cajun@moe new-1206]$ mech-dump
>> http://www.rfc-ignorant.org/tools/submit_form.php?table=whoi s
>> GET http://www.rfc-ignorant.org/tools/lookup.php
>> domain= (text)
>>
>> POST http://www.rfc-ignorant.org/tools/submit.php
>> table=whois (hidden readonly)
>> domain= (text)
>> evidence= (textarea)
>> submit=List me! (submit)
>>
>>
>> NOTE: There are two fields named 'domain'. This is part of my
>> problem I think.
>>
>> Also, If I try to explicitly put something in the 'evidence'
>> field, it's telling me there is no such field.
>>
>> Here's a snippet of the applicable code:
>>
>> my $browser = WWW::Mechanize->new();
>> # tell it to get the main page
>> $browser->get("http://rfc-ignorant.org/tools/submit_form.php ?t
>> able=whois");
>> $browser->field("domain", $_); # there are two fields named
>> domain $browser->field("evidence", @body); #
>> $browser->set_visible( $_, @body ); $browser->click();
>>
>> Thanks for any pointers where I'm going wrong.
>>
>> Mike
>>
Thanks Rich. I'm not sure about the form number. Maybe that is what
mech-dump is telling me is there are two forms. I'm not sure.
On this page, there is only one submit button. I've tried to explicitly
refer to it by 'List me!', but there was an error saying there wasn't
any button by that name.
Thanks,
Mike
--
Backup not found: A)bort, R)etry, M)assive heart failure?
21:10:01 up 18:01, 0 users, load average: 0.69, 0.50, 0.47
Linux Registered User #241685 http://counter.li.org