EDIT: Found a solution. Thanks everyone, particularly Corion.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.