perl 抓取网页内容

抓取乐彩网历年排列5数据

 

 use LWP::Simple;
 use FileOperate;
my $src = 'http://www.17500.cn/p5/all.php';
my $FileOperate = FileOperate->new();
my $FilePath = "C:\\Documents and Settings\\Administrator\\桌面\\PrelTest\\保存的模块\\文本处理";
#获取文件夹下所有内容


#http://www.17500.cn/p5/all.php?p=5

foreach my $index(1..200)
{
 $url=$src."?p=".$index;
 my @FileContent;
 #print "usl is $url\n";
  #my $input = <STDIN>;
 my $content = get $url;
 die "Couldn't get $url" unless defined $content;
 #  $content 里是网页内容,下面是对此内容作些分析:
 #print $content ;
 my $WriteFilePath = $index.".txt";
 push @FileContent,$content;
FileOperate->WriteFileContent($WriteFilePath,@FileContent);
undef @FileContent;

}

 my $input = <STDIN>;
 if($content =~ m/jazz/i) {
   print "They're talking about jazz today on Fresh Air!/n";
 } else {
    print "Fresh Air is apparently jazzless today./n";
 }

你可能感兴趣的:(perl,抓网页)