saving the outpult of a perl Mechanize::FireFox task

Einfach Dinge, die nichts mit XAMPP, Apache Friends, Apache, MySQL, PHP und alle dem zu tun haben. Allerlei halt. ;)

saving the outpult of a perl Mechanize::FireFox task

Postby unleash » 29. June 2013 15:50

good day dear apachefriends

i run a tiny little script with perl Mechanize :: Firefox

Code: Select all

use strict;
use warnings;

use WWW::Mechanize::Firefox;

my @urls = qw(

my $temp = '/tmp';
my $mech = WWW::Mechanize::Firefox->new('create');

foreach my $url (@urls){
   my ($name) = $url =~ /www\.(\w+)\.com/;
   print "creating $name.png\n";
   my $png = $mech->content_as_png(undef, undef, {width => 240, height => 240});
   my $file = "$temp/$name".".png";
   open my $fh, ">", $file or die "couldnt create $file";
   binmode $fh;
   print $fh $png;
   close $fh;

print "done\n";

Well if i run this above mentioned code it gives the following output in the termina
Code: Select all

martin@linux-70ce:~> cd perl
martin@linux-70ce:~/perl> ls  mech2
martin@linux-70ce:~/perl> perl
creating google.png
creating yahoo.png
creating cnn.png
creating bing.png
creating nbcnews.png
martin@linux-70ce:~/perl> ^C

well the above mentioned code will write the results to the /tmp directory, at the root level of the drive.
If we reboot, they'll be gone, but it's a place any process can write to regardless of user. That is the good thing.

We have to do some changes:
Well we have to do a change with the the directory to whatever location we want.

well i try to get the files created in a folder in /perl
Posts: 132
Joined: 03. December 2011 10:16
XAMPP Version: 5.6.3
Operating System: OpenSuse Linux 12.1

Return to Allerlei

Who is online

Users browsing this forum: No registered users and 2 guests