hya - good evening dear perl-folks
want to grab screenshots from sites like the following..
www.google.com
www.msnbc.com
news.bbc.co.uk
www.yahoo.com
for a mechanize-scraper i take this one here
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize::Firefox;
my $mech = new WWW::Mechanize::Firefox();
open(INPUT, "<url.txt") or die $!;
while (<INPUT>) {
chomp;
print "$_\n";
$mech->get($_);
my $png = $mech->content_as_png();
my $name = "$_";
$name =~s/^www\.//;
$name .= ".png";
open(OUTPUT, ">$name");
print OUTPUT $png;
sleep (5);
}
Well i forgot to mention that i only need to have the images as small thumbnails - so we do not have to have a very very large files...
i only need to grab a thumbnail screenshot of them. How do I do that?
my $png = $mech->content_as_png();
The line returns the given tab or the current page rendered as PNG image.
as the documentation states:
All parameters are optional. $tab defaults to the current tab. If the coordinates are given, that rectangle will be cut out. The coordinates should be a hash with the four usual entries, left,top,width,height. This is specific to WWW::Mechanize::Firefox.
Well does that have any impact on our code - can we make the code somewhat more specifical to our needs.
Note:the files i store are a bit smaller - if we limit them after fetching from the web !? aren īt they!?
BTW; Currently, the data transfer between Firefox and Perl is done Base64-encoded, isn t it. Well It would be beneficial to find what 's necessary to make JSON handle all the binary data more gracefully what do you think. Love to hear from you
Now i try to install mozrepl - if you or anybody has got some tipps on that. should i run
a. zypper in .or
b. get it as a firefox plugin
greetings
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.