Taking snapshot of a webpage

B

Bart Van der Donck

Can anyone help me how to take a snapshot of a webpage

#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;

my $webpage = 'http://www.google.com';

my $ua = new LWP::UserAgent;
$ua->agent("AgentName/0.1 " . $ua->agent);
my $req = new HTTP::Request GET => $webpage;
$req->content_type('text/html');
my $res = $ua->request($req);
unless ($res->is_success) {
die "Error: couldn't get $webpage: $!\n";
}

my $snapshot = $res->content; # $snapshot holds the html of $webpage

Hope this helps,
 
B

Bart Van der Donck

S

sujay.tukai

I have already tried the LWP method but the webpage, whose snapshot i
want to get contains lots of images, this takes a lot of toll on the
program which does the download. For eg., the webpage takes nearly a
minute to come..

Can u give me some other ideas by which i can convert the webpage to a
image and then use all the proxy and lwp thing to get it...
 
A

anno4000

I have already tried the LWP method but the webpage, whose snapshot i
want to get contains lots of images, this takes a lot of toll on the
program which does the download. For eg., the webpage takes nearly a
minute to come..

Can u give me some other ideas by which i can convert the webpage to a
image and then use all the proxy and lwp thing to get it...

Please don't use baby talk. Type "you", not "u". Saving two letters
may have been a good idea when connections ran at 300 Baud. Today
it's a childish affectation.

In another post you said:
I got it but my mai motive is to get the snapshot of the webpage by
using different proxies. So that i can detect the how the page is
viewed in different regions

If that is your motive you *must* download every bit of the page.
A consolidated image like you propose would have to be generated
on the server. It would only convey the server's idea of how the
page should look like. It would look the same everywhere.

If those are your web pages, take a hint and simplify them. If they
aren't, you'll have to download them.

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top