perl で、リモートの html ページをローカル マシンにダウンロードする方法を教えてください。例えば
http://example.com/catalog/lperl3/chapter/ch04.html
Perl を使用してこの HTML ソース コードをダウンロードする必要があります。
perl で、リモートの html ページをローカル マシンにダウンロードする方法を教えてください。例えば
http://example.com/catalog/lperl3/chapter/ch04.html
Perl を使用してこの HTML ソース コードをダウンロードする必要があります。
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";
}
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の最新版を入手する必要があります。
LWP::Simple モジュールの getstore を使用
use LWP::Simple;
getstore('http:://example.com/index.html', 'something.html');