http://stackoverflow.com/questions/22448574/need-suggestion-in-tricky-form-post-data-in-a-page-using-perl

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.