Hi,
I am trying to get a content of a web page using http inside a perl program.
for eg. if i pass a url address for e.g. " the script should fetch the result page and output return should be the text content of the page.
I am trying to call another script located in another machine, and that script suppose to update the database using the variable that i passed.
I tried using LWP module , downloaded from CPAN, but still can;t get the result. below is the code that i tried. Please help.
Thank You.
Regards,
Tirumaran M
tiru@tmm.com.my
---------------------------------------------------------------------------------------------------
#!/perl/bin/perl
# Create a user agent object
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$ua->agent("AgentName/0.1 " . $ua->agent);
# Create a request
my $req = new HTTP::Request POST => '$req->content_type('application/x-$req->content('cmd=view&id=784');
# Pass request to the user agent and get a response back
my $res = $ua->request($req);
print "before";
print $res->content;
print "after";
# Check the outcome of the response
if ($res->is_success) {
print $res->content;
} else {
print "no content fetched\n";}
I am trying to get a content of a web page using http inside a perl program.
for eg. if i pass a url address for e.g. " the script should fetch the result page and output return should be the text content of the page.
I am trying to call another script located in another machine, and that script suppose to update the database using the variable that i passed.
I tried using LWP module , downloaded from CPAN, but still can;t get the result. below is the code that i tried. Please help.
Thank You.
Regards,
Tirumaran M
tiru@tmm.com.my
---------------------------------------------------------------------------------------------------
#!/perl/bin/perl
# Create a user agent object
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$ua->agent("AgentName/0.1 " . $ua->agent);
# Create a request
my $req = new HTTP::Request POST => '$req->content_type('application/x-$req->content('cmd=view&id=784');
# Pass request to the user agent and get a response back
my $res = $ua->request($req);
print "before";
print $res->content;
print "after";
# Check the outcome of the response
if ($res->is_success) {
print $res->content;
} else {
print "no content fetched\n";}