DelphiFAQ Home Search:
General :: Programming :: perl
General questions about perl.


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Recommended links on this topic:
Featured Article

How can a perl script automate HTML form transmissions?


How can a perl script automate HTML form transmissions (GET or POST)?


See the two examples. The first one fills out a login form with 2 fields ('username', 'password') and does a GET request.

The second snippet fills out the same form but transmits the data with a POST request.

Keep in mind that the target URL has to be the URL that is specified in the action tag of the HTML form. This is usually different from the URL where the form is presented on.




 use LWP::Simple;
 use URI::URL;
 my $url = url('');
 $url->query_form(username => 'peter', password => 'secret');
 $content = get($url);  



 use HTTP::Request::Common qw(POST);
 use LWP::UserAgent;
 $ua = LWP::UserAgent->new();
 my $req = POST '',
    [ username => 'peter', password => 'secret' ];
 $content = $ua->request($req)->as_string; 

Generated 12:01:31 on Aug 15, 2020