#!/perl/bin/perl -w
print "Content-type: text/html\n\n";

use WWW::Mechanize;
my $mech = WWW::Mechanize->new( );
$mech->agent_alias("Windows Mozilla");
use LWP::Simple;
use HTML::TableContentParser;

$mech->get("http://google.com/");

my $filename = "admin.htm";
print $mech->content;

print "done...............";

$mech->save_content($filename);

die "cud not save ",$mech->response->status_line unless $mech->success;
print "done...............";


here is part of my perl script.
the problem is, i am trying to save that web page but the file named "admin.htm" is not generated. also no error message is generated.
if i put the print $mech -> content statement after "$mech->save_content($filename);" statement, nothing appears on the screen(program must be terminated after $mech->save_content($filename) statement).

any help or suggestion is appreciated .

thnx in advance.

Recommended Answers

All 4 Replies

thats because google does not allow you to do what you are trying to do. If you want to hit google use their API.

#!/usr/bin/perl

require HTTP::Request;
require LWP::UserAgent;

$request = HTTP::Request->new(GET => 'http://google.com/');

$ua = LWP::UserAgent->new;
$response = $ua->request($request);

print $response->as_string();


a copy/page solution from http://cpan.uwinnipeg.ca/htdocs/libwww-perl/HTTP/Request.html

thnx lordspace,
but i want to automate saving page(ie. i want to save google or any other page to my hard drive.)
and i think mechanize should work for tht.

hope 2 c ur reply...
thnx again.......

thnx lordspace,
but i want to automate saving page(ie. i want to save google or any other page to my hard drive.)
and i think mechanize should work for tht.

hope 2 c ur reply...
thnx again.......

neways i got it.........

$mech->get( "http://google.com", ":content_file" => "d:/google.htm");

thts how i could save tht page......

thnx for ur suggestion.
u were very near...
bye........

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.