in reply to Check website has update file using www::mechanize

Show us what you tried and tell us how it failed.

Premature optimization is the root of all job security
  • Comment on Re: Check website has update file using www::mechanize

Replies are listed 'Best First'.
Re^2: Check website has update file using www::mechanize
by perlmad (Sexton) on May 25, 2016 at 06:35 UTC

    I have tried this

    # subroutine for file downloading and moves to corresponding location sub file_download { my @temp_download_file_names=@{$_[0]}; my @temp_download_url=@{$_[1]}; my $dir_path=$_[2]; my $dir_name=$_[3]; print "\n\n Please Wait file is Downloading \n\n"; for(my $ii=0;$ii<=$#temp_download_file_names;$ii++){ $mech->get($home_url.$temp_download_url[$ii]); $http_response=$mech->res(); if($http_response->is_success){ $filename=$http_response->filename(); } else { $filename="untitled"; } $mech->save_content($filename); system "mv ./$filename $dir_path$dir_name/"; print " File name",$filename," is Downloaded \ +n\n"; $mech->back(); } } }

    How Can i check the download file is updated or already downloaded???

      The following may help:

      #!/usr/bin/perl use warnings; use strict; use WWW::Mechanize; my $url = 'http://perlmonks.org/?'; my $mech = WWW::Mechanize->new(); my $response = $mech->head($url); my $modDate = $response->header('last-modified'); if (defined $modDate) { print "Modification date: $modDate\n"; } else { print "Last modification date not available\n"; }

      Prints:

      Modification date: Wed, 25 May 2016 07:45:13 GMT
      Premature optimization is the root of all job security