CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
WWW::Mechanize

 



raghunand
Novice

Jul 24, 2008, 3:55 AM

Post #1 of 7 (746 views)
WWW::Mechanize Can't Post

Hi,

I'm using WWW::Mechanize to log into a website (http).
The problem is, when the script executes, after logging in...
it reaches an intermediate page ("Please wait for a moment" page)...

and then, it doesn't move to the actual logged in page...
Even if i do a sleep for some time, the contents of the page do not change...

Raghu
#!
use WWW::Mechanize;
use Term::Readline;
use LWP::UserAgent;
use LWP::Debug qw(+);
use HTTP::Cookies;


#######USER CREDENTIALS#######
my $user = '';
my $pass = '';
my $file = "tx.tx";

my $url = 'URL';

my $agent = WWW::Mechanize->new();
$agent->cookie_jar(HTTP::Cookies->new(file =>"$file",autosave => 1));
###$agent->$cookie_jar();

$formname = 'login_form';
$agent->get($url);
#$agent->form_name($formname);
$agent->submit_form(
form_name => $formname,
fields => {
loginName => "$user",
loginPassword => "$pass",
}
);
my $output_page = $agent->content();
open (FILE, ">output.htm");
print FILE $output_page;
#print $output_page;
close (FILE);
exit(0);


KevinR
Veteran


Jul 24, 2008, 11:30 AM

Post #2 of 7 (730 views)
Re: [raghunand] WWW::Mechanize [In reply to] Can't Post

Sounds like javascript might be involved, in which case WWW::Mechanize will not work. If there is no javascript on the page that you are accessing then I don[t know what the problem is.
-------------------------------------------------


raghunand
Novice

Jul 24, 2008, 9:38 PM

Post #3 of 7 (713 views)
Re: [KevinR] WWW::Mechanize [In reply to] Can't Post

Yes, you are correct, i saw the redirect page...it did involve a java script.

In this case, what can be used?



Raghu


KevinR
Veteran


Jul 24, 2008, 10:09 PM

Post #4 of 7 (712 views)
Re: [raghunand] WWW::Mechanize [In reply to] Can't Post

I don't know what you could do, sorry. Ask on www.perlmonks.com and see if anyone has a suggestion.
-------------------------------------------------


raghunand
Novice

Jul 24, 2008, 10:43 PM

Post #5 of 7 (707 views)
Re: [KevinR] WWW::Mechanize [In reply to] Can't Post

Ok...

there are a few modules (i got this from perlmonks)

WWW::Mechanize::Javascript (that's in alpha code tho)

Win32::IE::Mechanize can also be used...

I've not tried them...

Will try and let you guys know...


KevinR
Veteran


Jul 24, 2008, 11:24 PM

Post #6 of 7 (706 views)
Re: [raghunand] WWW::Mechanize [In reply to] Can't Post

great, thanks for posting back. Good luck.
-------------------------------------------------


raghunand
Novice

Jul 25, 2008, 12:38 PM

Post #7 of 7 (685 views)
Re: [KevinR] WWW::Mechanize [In reply to] Can't Post

Hey did it...

javascript problem + loading problem...

asked the script to sleep till the loaded document was html.. & also used Win32::IE::Mechanize.

That did the trick :)

Raghu

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives