Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Don't ask to ask, just ask
 
PerlMonks  

WWW::Mechanize and text input outside form

by fauria (Deacon)
on Jan 05, 2005 at 13:36 UTC ( [id://419693]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

fauria has asked for the wisdom of the Perl Monks concerning the following question:

Hi all!

Im writing a spider using WWW::Mechanize, and ive found a web with a login box out of a <form> tag. <input type's> are not inside any form, and WWW::Mechanize says:

<input> outside <form> at /usr/lib/perl5/site_perl/5.8.3/WWW/Mechanize.pm line 1335

Is there any way of filling this boxes (are username and password), and hit the submit button?

Thank you!

Retitled by davido.

  • Comment on WWW::Mechanize and text input outside form

Replies are listed 'Best First'.
Re: WWW::Mechanize and text input outside form
by Corion (Patriarch) on Jan 05, 2005 at 13:40 UTC

    No. Or rather, in principle yes, but it won't work as you want it to work, as input fields outside of form tags will never be submitted by the browser, except via Javascript. And WWW::Mechanize does not understand Javascript.

      Although you could rewrite the HTML so that the input field was inside the form tags...

      # untested; salt to taste my $html = $mech->content; $html =~ s/(<input[^>]+>)(.*?<form[^>]*>)/$2$1/; $mech->update_html($html);

          --k.


Re: WWW::Mechanize and text input outside form
by PodMaster (Abbot) on Jan 05, 2005 at 13:46 UTC
    Yes, but not by using ->value() because that (<input> outside of <form>) is not valid html. You would need to use ->request().

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://419693]
Approved by Corion
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.