GrSrv
GrSrv

Reputation: 559

How to convert HTML to JPEG/PNG

Is there a way in Perl to get the contents of an URL in IMAGE format?

I can use LWP::Simple to get HTML, but still can't figure out how to get it in JPEG

Upvotes: 3

Views: 1729

Answers (1)

mahnkong
mahnkong

Reputation: 355

You could us the Wight module, which allows usage of phantomjs from Perl. An example which renders a page to a .png file would look like:

use strict;
use Wight;

my $wight = Wight->new;

$wight->visit('http://www.google.com/');
$wight->render('google.png');

Another possibility would be to use the Perl selenium API in combination with phantomjs, as described in this blog article.

Upvotes: 6

Related Questions