in reply to Download web page including css files, images, etc.
As a fair warning the above is definitely untested and probably horribly over-simplified, but the basic idea seems sound to me.use HTTP::Lite; my $http = new HTTP::Lite; my $req = $http->request("http://www.something.com") or die "Unable to get document: $!"; my $mirror_home = '/home/user/mirror_home/'; my (@javascript, @css, @jpg); my $i = 0; while ($http->body()){ if ($_ =~ m/*.jpg/){ push $_, @jpg;} else if ($_ =~ m/*.js/){ push $_, @javascript;} else if ($_ =~ m/*.css/){ push $_, @css;} } open FILE, "> $mirror_home/index.html" or die "Couldn't open $mirror_home/index.html : $!"; print FILE $http->body(); close FILE; while ($i <= $#css){ $req = $http->request("http://www.something.com/$css[$i]") or die "Unable to get document: $!"; open FILE, "> $mirror_home/$css[$i]"; print FILE $http->body(); close FILE; $i++ } $i = 0; # Then repeat for other extensions.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Download web page including css files, images, etc.
by trendle (Novice) on Feb 08, 2012 at 03:25 UTC |