A simple program to take a screencapture of a webpage in a web-browser (in this case Firefox).
#!/usr/bin/perl -w use warnings; use strict; use WWW::Mechanize::Firefox; my $url = "http://cmcc.deviantart.com"; my $outfile = "MyScreenshot.png"; my $telnet_max_buff_len = 10485760; my $mech = WWW::Mechanize::Firefox->new( launch => 'firefox',); my $net_telnet = $mech->repl->repl->client; # Bridge deep into WWW:Tel +net for finer control $net_telnet->telnet->max_buffer_length($telnet_max_buff_len); # Enable + buffer size to handle large webpage $mech->get($url); # Grab the content my $png = $mech->content_as_png(); # Dump to a PNG file open my $out, '>', $outfile or die "Couldn't create '$outfile': $!"; binmode $out; # Enable binary mode print {$out} $png; # Write the file to disk
You will need to have WWW::Mechanize::Firefox installed (which can be done through cpan), and you will need to have the firefox addon MozRepl installed (http://wiki.github.com/bard/mozrepl). Module::Pluggable::Fast is, for some reason, not installable through the CPAN shell. You will need to download it separately and extract and install it manually by doing the following dance:
1. Download Module::Pluggable::Fast
2. Extract the tarball somewhere convenient
3. Open a shell in that directory
4. Type cpan . (including that dot)
5. Watch the module get installed
6. Retry installing WWW::Mechanize::Firefox
This should work. Thanks everyone again.
In reply to Screencapture with Perl on Linux (SOLVED) by sadarax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |