Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
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 avoiding work at the Monastery: (14)
As of 2015-07-02 12:33 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 (36 votes), past polls