> Try to use WWW::Mechanize always.

Perfect, that looks like it will work great.  In fact, it has some other
methods that should be more useful than the library I'm using now.
Actually, I'm not quite sure why you're using:

> $agent->{form}->{action} = URI->new('http://www.server.com/login');

I don't even see this functionality in the documentation.  But
$agent->submit_form() will work for me so that isn't a problem.

Another issue has popped up however with Mechanize.  It doesn't seem to
allow me to set the value of hidden fields in a form.  When I attempt this I
get the error:

> Input 'txtAction' is readonly at
/usr/lib/perl5/site_perl/5.8.2/WWW/Mechanize.pm line 507

Commenting this part out allows the page to continue, but this field must be
set to move on through the site.  Any ideas how I can get around this?

Out of curiousity, has anyone attempted to develop a Javascript enabled web
client for Perl?  A lot of what I end up doing is 10 times as complicated
because I have to figure out what the Javascript on web pages is doing and
somehow duplicate it. This is usually limited to automatic form submission,
redirects, etc.  But it is still annoying!

Thanks,

Brett

-----Original Message-----
From: JUANMARCOSMOREN [mailto:[EMAIL PROTECTED]
Sent: Sunday, June 06, 2004 7:54 AM
To: Brett
Subject: Re: Submitting HTTP-Request-Form
Importance: High


Brett wrote:
> I've been using the HTTP-Request-Form module for several months now to
> automate some tasks that are available through web interfaces.  Its been
> working very well, but I'm currently working on a script that involves
> logging into a site.  This site unfortunately uses lots of Javascript.
> Instead of having a submit button on the login form, clicking on an image
> causes an onClick javascript function to submit the form.
>
> Has anyone run into this?  I don't see a general submit function in the
> module, so I'm not sure if there is a way to submit forms besides a submit
> type input click.

Try to use WWW::Mechanize always.

This is a workaround I use:
my $agent = WWW::Mechanize->new();
my $res = $agent->get('http://www.server.com/');
if ($res->is_success) {
  if ($agent->form_name('form')) {
    $agent->{form}->{action} = URI->new('http://www.server.com/login');
  }
}

Is this the best way to use WWW::Mechanize code anyway, Andy?

Juan



Reply via email to