Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Question about WWW::Mechanize

by redss (Monk)
on Jan 10, 2008 at 23:37 UTC ( #661757=perlquestion: print w/ replies, xml ) Need Help??
redss has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I want to submit a form, and the following works:

use WWW::Mechanize; $mech = WWW::Mechanize->new(); $mech->get('http://www.abc.com/index.htm' ); $resp = $mech->submit();
However, I want to embed the html (containing the form) in my perl script rather than retrieving it using $mech->get.

How can I do that?

My Mechanize.pm is version .72 which doesn't have an update_html() method, which sounds like one way to do it.

Comment on Question about WWW::Mechanize
Download Code
Re: Question about WWW::Mechanize
by gam3 (Curate) on Jan 11, 2008 at 01:22 UTC
    The very simplest way is to change the url:
    use WWW::Mechanize; $mech = WWW::Mechanize->new(); $mech->get('file://localhost/tmp/bob.html'); $resp = $mech->submit();
    Here the form is read from /tmp/bob.html.
    -- gam3
    A picture is worth a thousand words, but takes 200K.
Re: Question about WWW::Mechanize
by davidrw (Prior) on Jan 11, 2008 at 01:24 UTC
    WWW::Mechanize is up to version 1.34 ... (if you really can't upgrade for whatever reason, you can try to subclass it yourself to add update() taken from the source of a newer version)
    my $mech = WWW::Mechanize->new(); $mech->get('.'); # to make it internall create request/response objec +ts $mech->update_html($html); # then use normally
    WWW::Mechanize::Cached may be of interest as well
Re: Question about WWW::Mechanize
by Gangabass (Priest) on Jan 11, 2008 at 03:03 UTC

    Install new version of WWW::Mechanize?

    Or look into WWW::Mechanize (version 1.34) sources how update_html() implemented...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://661757]
Approved by lidden
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2014-09-17 21:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (100 votes), past polls