草莓Perl和lwp - 下载并保存不起作用

时间:2013-12-03 20:37:49

标签: perl download lwp

此代码适用于ActiveState Perl 5.10,但使用Strawberry Perl 5.14则失败。 它部分下载和保存jpeg,从一开始就只有4Kb左右。每次下载文件的大小都不同。 响应总是“200 OK”。 LWP版本是6.04

use 5.14.0;
use LWP::UserAgent;
use HTTP::Headers;

my $img = 'https://avoncontent6.com/assets/ru-ru/images/product/prod_5045704_1_613x613.jpg';

my $ua = new LWP::UserAgent;
my $hh = HTTP::Headers->new(
  'User-Agent' => 'Mozilla/5.0 (Windows NT 5.1; rv:21.0) Gecko/20100101 Firefox/21.0',
  'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  'Accept-Language' => 'en-us,en;q=0.7,ru;q=0.3',
  'Accept-Encoding' => 'gzip, deflate',
  'Connection' => 'keep-alive',
);
$ua->default_headers( $hh );
$ua->cookie_jar({});
$ua->timeout(20);

$ua->get($img, ':content_file' => "jpg/1.jpg");

标题是:

HTTP/1.1 200 OK
Date: Tue, 03 Dec 2013 20:32:14 GMT
Accept-Ranges: bytes
ETag: "031dd727cfce1:0"
Server: Microsoft-IIS/8.0
Content-Length: 149607
Content-Type: image/jpeg
Last-Modified: Tue, 22 Oct 2013 13:08:46 GMT
Client-Aborted: die
Client-Date: Tue, 03 Dec 2013 20:32:15 GMT
Client-Peer: 162.13.51.77:443
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=EssentialSSL CA
Client-SSL-Cert-Subject: /OU=Domain Control Validated/OU=Free SSL/CN=avoncontent6.com
Client-SSL-Cipher: RC4-SHA
Client-SSL-Socket-Class: IO::Socket::SSL
X-Died: read failed: Inappropriate I/O control operation at D:/perl/perl/vendor/lib/LWP/Protocol/http.pm line 414.
X-Powered-By: ASP.NET

1 个答案:

答案 0 :(得分:0)

安装旧版本libwww-perl-5.837