Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Check website has update file using www::mechanize

by GrandFather (Saint)
on May 25, 2016 at 06:06 UTC ( [id://1164036]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1164036]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-20 03:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found