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

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???

Replies are listed 'Best First'.
Re^3: Check website has update file using www::mechanize
by GrandFather (Saint) on May 25, 2016 at 07:49 UTC

    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