Tags

, , , ,

#!/usr/bin/perl
use LWP::Simple;
use LWP;

# scan all files in folder
sub scanFolder {
   my $dirtoget    = ".\\yourPath\\";
   opendir(IMD, $dirtoget) || die ("Cannot open directory");
   my @thefiles    = readdir(IMD);
   foreach $f (@thefiles)    {
      unless (($f eq ".") || ($f eq "..") )
      {
         my $filename = $dirtoget.$f;
         // do what you want ^^
      }
   }
   closedir(IMD);
}

sub saveImagesFromWWW    {
   my ($filename, $target) = @_;
   my $browser = LWP::UserAgent->new;

   # Get image from hotlink protection
   my $response = $browser->get(
         $filename, # image path
         'Referer' =>   # The URL where I see the strip:
         "http://yourWantedPage.......html",
      );
   $fileOutput = ".\\outputPath\\".$target.".jpg";
   open(OUT, ">".$fileOutput) || die $!;
   binmode(OUT);
   print OUT $response->content;
   close(OUT);
}
Advertisements