Reputation: 11098
I would like to post the below data to a particular URL:
choice yes
high high
low low
name BDNL
To this URL:
https://www.example.com
I would then like to save the response whether HTML or plain text in a text file?
I have experience with Perl and would prefer to use it for the purpose of this task.
Upvotes: 0
Views: 120
Reputation: 5159
You could use LWP::UserAgent
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
use CGI;
my $url = 'http://www.example.com/';
my $ua = LWP::UserAgent->new();
my $response = $ua->post( $url, { choice => "yes", high => "high", low => "low", name => "BDNL" } );
my $content = $response->decoded_content();
my $cgi = CGI->new();
open my $fh, ">", "response.txt" or die "$!";
print $fh $cgi->header() . $content;
close $fh;
Upvotes: 1