User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Perl section within the Software Development category of DaniWeb, a massive community of 423,607 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,252 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Perl advertiser: Programming Forums
Views: 2490 | Replies: 4 | Solved
Reply
Join Date: Apr 2007
Posts: 34
Reputation: devesh9392 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
devesh9392 devesh9392 is offline Offline
Light Poster

perl mechanize $mech->save_content($filename) problem

  #1  
Jun 4th, 2007
#!/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:imple;
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2006
Posts: 618
Reputation: KevinADC is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 33
KevinADC's Avatar
KevinADC KevinADC is offline Offline
Practically a Master Poster

Re: perl mechanize $mech->save_content($filename) problem

  #2  
Jun 4th, 2007
thats because google does not allow you to do what you are trying to do. If you want to hit google use their API.
Last edited by KevinADC : Jun 4th, 2007 at 11:32 pm.
Reply With Quote  
Join Date: May 2006
Location: Canada
Posts: 46
Reputation: lordspace is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 3
lordspace's Avatar
lordspace lordspace is offline Offline
Light Poster

Re: perl mechanize $mech->save_content($filename) problem

  #3  
Jun 5th, 2007
#!/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/libw...P/Request.html
Reply With Quote  
Join Date: Apr 2007
Posts: 34
Reputation: devesh9392 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
devesh9392 devesh9392 is offline Offline
Light Poster

Re: perl mechanize $mech->save_content($filename) problem

  #4  
Jun 5th, 2007
Originally Posted by lordspace View Post
#!/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/libw...P/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.......
Reply With Quote  
Join Date: Apr 2007
Posts: 34
Reputation: devesh9392 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
devesh9392 devesh9392 is offline Offline
Light Poster

Re: perl mechanize $mech->save_content($filename) problem

  #5  
Jun 5th, 2007
Originally Posted by devesh9392 View Post
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........
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Perl Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Perl Forum

All times are GMT -4. The time now is 8:34 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC