On Thu, 29 Mar 2007 09:00:02 +0800, Jeff Pang wrote: >>What's the best way to go about making an HTTP POST? >>I want to retrieve a dynamic page that is only accessable via a POST. >>Is there a module (simple one?) that deals with this? > > From 'perldoc lwpcook', > > use HTTP::Request::Common qw(POST); > use LWP::UserAgent; > $ua = LWP::UserAgent->new; > > my $req = POST 'http://www.perl.com/cgi-bin/BugGlimpse', > [ search => 'www', errors => 0 ]; > > print $ua->request($req)->as_string; > > This is maybe the simplest way I knew.
Even simpler if there is a web page containing a form that POSTs to that page is to use WWW::Mechanize. Then it would be as simple as: use WWW::Mechanize; my $ua = WWW::Mechanize->new; $ua->get( 'http://whatever.example.com/' ); $ua->submit_form( fields => { search => 'www', errors => 0 } ); print $ua->content; (The last line is probably more useful than the literal translation of print $ua->res->as_string; ) -- Peter Scott http://www.perlmedic.com/ http://www.perldebugged.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/