amitsq has asked for the wisdom of the Perl Monks concerning the following question:
my $ua = LWP::UserAgent->new( verify_hostname => 0); #downloading the form: $ua->cookie_jar($cookie_jar); $ua->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; In +foPath.1; .NET CLR 2.0.50727)'); my $url = www.anywebsite.com my $response = $ua->get($url); die "Couldn't get $url", $response->status_line unless $response->is_ +success; #submitting the form: $keyword = "asdsa"; $Search_url ="www.wheretosubmit.com"; $param = 'showType=1&strSources=&strWhere='.$strWhere.'&numSortMethod= +&strLicenseCode=&numIp=&numIpc=&numIg=&numIgc=&numIgd=&numUg=&numUgc= +&numUgd=&numDg=&numDgc=&pageSize=3&pageNow=1'; $request = HTTP::Request->new('POST', $Search_url); $request->header('Content-Type' => 'application/x-www-form-urlencoded' +); $request->header('Referer' => "www.webpage.com"); $request->header('Accept' => 'text/html,application/xhtml+xml,applicat +ion/xml;q=0.9,*/*;q=0.8'); $request->header('Connection' => 'keep-alive'); $request->content($param); $response = $ua->request($request); $page = $response->decoded_content(); #parsing $page to catch the captcha image and get the user recognition ... #trying to send captcha text away: while(defined($captcha)){ $param="numIg=&numDgc=&numIgc=&numIp=&pageSize=20&strWhere='.$strWhere +.'&numDg=&numIpc=&numUgc=&numUgd=&strLicenseCode=&numIgd=&showType=1& +numSortMethod=&strSources=&numUg=&pageNow=1&vct='.$captcha.'&Submit=% +E7%BB%A7%E7%BB%AD"; $Search_url ="www.webpage.com"; $request = HTTP::Request->new('POST', $Search_url); $request->header('Host' => 'www.webpage.com' ); $request->header('Accept' => 'text/html,application/xhtml+xml,applicat +ion/xml;q=0.9,*/*;q=0.8'); $request->header( 'Referer' => "www.webpage.action"); $request->header('Connection' => 'keep-alive'); $request->content($param); $response = $ua->request($request); $page = $response->decoded_content(); ##instead of accepting the captcha submit and leading on the result pa +ge, the webpage reload ( and just to another captcha)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: LWP Cookies
by dbander (Scribe) on Aug 01, 2017 at 02:02 UTC |