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

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('' ); $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 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://661757]
Approved by lidden
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2018-03-18 16:07 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (230 votes). Check out past polls.