0

perl で、リモートの html ページをローカル マシンにダウンロードする方法を教えてください。例えば

http://example.com/catalog/lperl3/chapter/ch04.html

Perl を使用してこの HTML ソース コードをダウンロードする必要があります。

4

3 に答える 3

4

LWP::Simpleモジュールを見てください。

use strict;
use warnings;
use LWP::Simple;

my $status = getstore('http://myweb.com/catalog/lperl3/chapter/ch04.html', 'ch04.html');
unless (is_success($status)) {
  die "An error has occured! Status code: $status\n";
}
于 2012-05-08T14:18:37.947 に答える
1

Mojo::UserAgentを使用できます:

use Mojo::UserAgent;

my $url = 'http://oreilly.com/catalog/lperl3/chapter/ch04.html';

Mojo::UserAgent
    ->new
    ->get( $url )
    ->res
    ->content
    ->asset
    ->move_to( 'ch04.html' )

ただし、 Learning Perlの最新版を入手する必要があります。

于 2012-05-08T20:35:24.827 に答える
1

LWP::Simple モジュールの getstore を使用

use LWP::Simple;
getstore('http:://example.com/index.html', 'something.html');
于 2012-05-08T14:15:17.740 に答える