Skip to content

Instantly share code, notes, and snippets.

@mash
Created May 19, 2010 07:53
Show Gist options
  • Save mash/406076 to your computer and use it in GitHub Desktop.
Save mash/406076 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use WWW::Mechanize::Firefox;
die "usage: $0 <url> <filename>"
unless scalar @ARGV == 2;
my ($url, $file) = @ARGV;
my $mech = WWW::Mechanize::Firefox->new(
#tab => 'current',
bufsize => 10 * 1024 * 1024, # 10 MB
autoclose => 1,
);
$mech->get( $url );
my $png = $mech->content_as_png();
my $fh = new IO::File "> $file";
if (defined $fh) {
print $fh $png;
$fh->close;
}
print "wrote: $url => $file\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment