无法使用所需页面Perl LWP重定向

时间:2013-07-30 11:01:51

标签: perl lwp

我有搜索页面,点击搜索时会返回结果。搜索页面的网址在结果页面中不同

在浏览器中重定向okie。但在LWP Perl中,它重定向了相同的页面。你有什么建议吗?

#!/usr/bin/perl
use LWP::UserAgent

$uri = 'http://bsneny.prismisp.com/Search';
my $json = 'SearchType=ByProvider&ProviderType=Provider&Plan=66&Tier=0&City=&County=&State=NY&Zip=12110&Address=12110&Proximity=10&PrimaryCareProvider=false&Specialty=0&Name=';
my $req = HTTP::Request->new( 'POST' => $uri );
$req->header( 'Content-Type' => 'application/x-www-form-urlencoded' );
$req->content( $json );
my $lwp = LWP::UserAgent->new(requests_redirectable => [ 'GET', 'HEAD', 'POST' ]);
my $res = $lwp->request( $req );
  if ($res->is_success) {
      print $res->content;
  }
  else {
      print $res->status_line, "\n";
 }

这是HTTP标头

Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://bsneny.prismisp.com/
Cookie: __utma=46389044.678583325.1374547830.1374547830.1375169639.2; __utmz=46389044.1374547830.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); ASP.NET_SessionId=mpe4knby1rnlzm2e4noh5mew; __utmb=46389044.1.10.1375169639; __utmc=46389044
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 162

0 个答案:

没有答案