从百度下载mp3

一个很有限的下载功能,没怎么扩展。目的就是从百度下载一下mp3
代码:
把下载的url存到本地的一个 文本文件里:
# !/usr/bin/perl
# Script one :get_the_url.pl
#
use LWP::Simple;
my $url  = "http://mp3.baidu.com/m?f=ms&rn=&tn=baidump3&ct=134217728&word=%D0%ED%CE%A1&lm=-1";
my $con  = get($url);
my @list ;
my @final;
push @list, $1 while ($con =~ /<a/s+href=[/'/"]?(https?/://///d{1,3}/./d{1,3}/./d{1,3}/./d{1,3}[^/"]*?)/"/isg);
for (@list) {
 my $content = get($_);
 while ($content =~ /<a href="([^"]+?)"/igs) {
    print $1."/n";
 }
}


#!/usr/bin/perl
# Script two: download.pl
# Say: the one print to "mp3.list"   <--------------------------------
use LWP::Simple;
my %type = (mp3=>1, wav=>1 ,Wma=>1 ,rm=>1 ,wma=>1);
my $dic = "./mp3/";

open F,"mp3.list";
while (<F>) {
  if (/.*//(.*)/) {
   my ($a,$b) = split //./ig,$1;
   next unless $type{$b};
   getstore($_, $dic.$1);
  }
}
close F;
~   





你可能感兴趣的:(list,百度,url,扩展)