简体   繁体   English

Strawberry Perl和LWP-无法下载并保存

[英]Strawberry Perl and lwp - download and save doesn't work

This code worked with ActiveState Perl 5.10, but with Strawberry Perl 5.14 it fails. 该代码可用于ActiveState Perl 5.10,但可用于Strawberry Perl 5.14,但失败。 It downloads and saves jpeg partially, only 4Kb or so from the beginning. 它从一开始就下载和保存jpeg的部分内容,只有4Kb左右。 And every time size of downloaded file differs. 并且每次下载文件的大小都不同。 Response is always "200 OK". 响应始终为“ 200 OK”。 LWP version is 6.04 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");

Headers are: 标头为:

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

已安装旧版本libwww-perl-5.837

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM