#!/usr/bin/perl -w
use strict;
use warnings;
use WWW::Mechanize;
my $URL = 'http://www.zipsites.ru/music/kino/';
my $BROWSER_AGENT = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)';
my $WGET = '/usr/bin/wget';
my $MP3DIR = '/tmp/kino';
my $browser = WWW::Mechanize->new(agent => $BROWSER_AGENT, onerror => undef, stack_depth => 1);
$browser->add_header('Accept-Encoding' => undef);
my $r = $browser->get($URL);
unless ($browser->success){
print "Can't get url\n";
exit;
}
foreach($browser->links()){
my $url = $_->url();
if($url =~ /.+\/(.+)\/(.+)\.mp3$/i){
mkdir($MP3DIR) if(!-e($MP3DIR));
mkdir("$MP3DIR/$1") if(!-e("$MP3DIR/$1"));
if(!-e("$MP3DIR/$1/$2.mp3")){
system("$WGET --user-agent='$BROWSER_AGENT' -P \"$MP3DIR/$1\" \"$url\"");
}
else{
print "\"$2\" already exists! Skip.\n";
}
}
}
print "DONE!\n";
Может кому пригодится...