Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: how to submit html form?

by gu (Beadle)
on Nov 27, 2005 at 19:26 UTC ( #512038=note: print w/ replies, xml ) Need Help??


in reply to how to submit html form?

It's as easy as :

use WWW::Mechanize ; my $m = WWW::Mechanize->new ; my %conf = ( foo => bar ) ; $m->get("http://your.url/") ; die $m->res->status_line unless $m->success ; # Choose form number $m->form_number(1) ; # Fill $m->set_fields( %conf ) ; # Submit $m->submit ; die $m->res->status_line unless $m->success ; # If the form sends you somewhere, you can catch it : my $url = $m->response->request->uri->as_string ;
Then if you want to process HTML data from a page, I recommend you use HTML::TreeBuilder, for example as :
$m->get("$url") ; die $m->res->status_line unless $m->success ; my $tree = HTML::TreeBuilder->new_from_content( $m->content ) ;

Gu


Comment on Re: how to submit html form?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2014-07-30 15:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (235 votes), past polls