Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Question about WWW::Mechanize

by redss (Monk)
on Jan 10, 2008 at 23:37 UTC ( [id://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.

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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-23 23:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found