Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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
Replies are listed 'Best First'.
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 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 Gangabass (Vicar) 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 making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2015-07-08 07:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (96 votes), past polls