WWW::Mechanize question
am 14.12.2006 05:58:29 von cajun
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 ?table=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
--
The programmer's national anthem is 'AAAAAAAAHHHHHHHH'. -Weinberg, p.152
23:50:01 up 14 days, 13:16, 0 users, load average: 0.07, 0.29, 0.33
Linux Registered User #241685 http://counter.li.org
RE: :Mechanize question
am 14.12.2006 19:46:56 von RDuz
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' =3D> '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
=20
> -----Original Message-----
> From: M. Lewis [mailto:cajun@cajuninc.com]=20
> Sent: Wednesday, December 13, 2006 10:58 PM
> To: libwww@perl.org
> Subject: WWW::Mechanize question
>=20
>=20
> I've used WWW::Mechanize before, but not for posting to a=20
> form on the web. I'm trying to automate some very boring=20
> postings of spammers to the rfci website. I'm not having much=20
> luck with it.
>=20
> mech-dump tells me:
>=20
> [cajun@moe new-1206]$ mech-dump
> http://www.rfc-ignorant.org/tools/submit_form.php?table=3Dwh ois
> GET http://www.rfc-ignorant.org/tools/lookup.php
> domain=3D (text)
>=20
> POST http://www.rfc-ignorant.org/tools/submit.php
> table=3Dwhois (hidden readonly)
> domain=3D (text)
> evidence=3D (textarea)
> submit=3DList me! (submit)
>=20
>=20
> NOTE: There are two fields named 'domain'. This is part of my=20
> problem I think.
>=20
> Also, If I try to explicitly put something in the 'evidence'=20
> field, it's telling me there is no such field.
>=20
> Here's a snippet of the applicable code:
>=20
> my $browser =3D WWW::Mechanize->new();
> # tell it to get the main page
> $browser->get("http://rfc-ignorant.org/tools/submit_form.php ?t
> able=3Dwhois");
> $browser->field("domain", $_); # there are two fields named=20
> domain $browser->field("evidence", @body); #=20
> $browser->set_visible( $_, @body ); $browser->click();
>=20
> Thanks for any pointers where I'm going wrong.
>=20
> Mike
>=20
> --=20
>=20
> The programmer's national anthem is 'AAAAAAAAHHHHHHHH'. =20
> -Weinberg, p.152
> 23:50:01 up 14 days, 13:16, 0 users, load average: 0.07,=20
> 0.29, 0.33
>=20
> Linux Registered User #241685 http://counter.li.org
>=20