I am trying to Post and get some response data, but i am getting the same data as response even after changing the data values in the post request. i am in need of some suggestion , this is what i have tried
use strict; use warnings; use LWP::UserAgent; use WWW::Mechanize; my $mech=WWW::Mechanize->new(); my $ua = LWP::UserAgent->new; my $server_endpoint ='http://www.dartsmad.com/dartabase/darts_player_h +ead_to_head.aspx'; $mech->get($server_endpoint); my $content=$mech->content(); my $eventtarget=''; my $eventargument=''; my $lastfocus=''; my $viewstate=''; my $validation=''; if($content=~m/id="__EVENTTARGET"\s*value="([^"]*?)"/is){$eventtarget= +$1;print $1."\n\n\n\n\n\n __EVENTTARGET";sleep 2;} if($content=~m/id="__EVENTARGUMENT"\s*value="([^"]*?)"/is){$eventargum +ent=$1;print $1."\n\n\n\n\n\n __EVENTARGUMENT";sleep 2;} if($content=~m/id="__LASTFOCUS"\s*value="([^"]*?)"/is){$lastfocus=$1;p +rint $1."\n\n\n\n\n\n __LASTFOCUS";sleep 2;} if($content=~m/id="__VIEWSTATE"\s*value="([^"]*?)"/is){$viewstate=$1;p +rint $1."\n\n\n\n\n\n view_state";sleep 2;} if($content=~m/id="__EVENTVALIDATION"\s*value="([^"]*?)"/is){$validati +on=$1;print $1."\n\n\n\n\n\n__EVENTVALIDATION";sleep 2;} my $post_data = '{"__EVENTARGUMENT":'.$eventargument.',"__VIEWSTATE":' +.$viewstate.',"__EVENTTARGET":'.$eventtarget.',"__EVENTVALIDATION":'. +$validation.',"__LASTFOCUS":'.$lastfocus.',"btnComparePlayers":"Compa +re","ddlCompPlayerA":"246",ddlCompPlayerB:"259"}'; my $req = HTTP::Request->new(POST => $server_endpoint); $req->header('Content-Type: application/x-www-form-urlencoded'); $req->content($post_data); my $resp = $ua->request($req); if ($resp->is_success) { my $message = $resp->decoded_content; print "Received reply: $message\n"; open(FH,">txk.html"); print FH $message; close FH; } else { print "HTTP POST error code: ", $resp->code, "\n"; print "HTTP POST error message: ", $resp->message, "\n"; }
In reply to Need suggestion in Post data request using perl by Balakumar_P
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |