Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > FAQ 9.9 How do I automate an HTML form submission?

Thread Tools

FAQ 9.9 How do I automate an HTML form submission?

PerlFAQ Server
Posts: n/a
This is an excerpt from the latest version perlfaq9.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at .


9.9: How do I automate an HTML form submission?

If you are doing something complex, such as moving through many pages
and forms or a web site, you can use "WWW::Mechanize". See its
documentation for all the details.

If you're submitting values using the GET method, create a URL and
encode the form using the "query_form" method:

use LWP::Simple;
use URI::URL;

my $url = url('');
$url->query_form(module => 'DB_File', readme => 1);
$content = get($url);

If you're using the POST method, create your own user agent and encode
the content appropriately.

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;

$ua = LWP::UserAgent->new();
my $req = POST '',
[ module => 'DB_File', readme => 1 ];
$content = $ua->request($req)->as_string;


The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
can ruby automate form submission? Simon Jackson Ruby 2 02-23-2007 03:21 AM
code generation/automate DDL,DML,JSP,HTML Java 0 12-15-2005 11:47 AM
How to automate Excel from C#.NET Giorgos Zagouras ASP .Net 0 01-07-2004 01:25 PM
how can i automate this? Someone Perl 1 08-21-2003 05:24 AM