从Web下载文件

时间:2013-02-09 08:24:11

标签: perl

当我试图从Web下载文件时,我编写了一个脚本,但它正在下载URL而不是文件。任何人都可以让我知道我在哪里做错了:

这是脚本:

use strict;
use warnings;
use WWW::Mechanize;

    my $path_to_files =   'http://www.filehippo.com/download_google_talk/download';
    my $mech = WWW::Mechanize->new();
    $mech->get( $path_to_files );
    $mech->save_content( "download_google_url.html" );#save the base to see how it looks  like
    my @link_arr = $mech->links();
    foreach my $link_ref (@link_arr)
    {
     foreach my $real_link (@$link_ref) 
     {
      #print "I am here \n";
      if($real_link =~ /^Google/gi)
      {
        print "$real_link\n";
        my $fname = $real_link;
        $fname .= ".exe";
        $mech->get($real_link,":content_file" => "$fname" );
      }
      # print " link is : $real_link\n";   
     }

    }

我采用了

的逻辑

Perl script for Downloading the file from web

这里。

0 个答案:

没有答案