Re: Perl Script to login to a secure WebSite
by ckj (Chaplain) on Aug 03, 2012 at 06:28 UTC
|
You are using wrong form name and field names too.
Through the same code I was able to login to gmail :
use strict;
use warnings;
use strict;
use WWW::Mechanize;
use HTTP::Cookies;
my $outfile = "out2.htm";
my $url = "https://accounts.google.com/ServiceLogin?service=mail&passi
+ve=true&rm=false&continue=http://mail.google.com/mail/&scc=1<mpl=de
+fault<mplcache=2";
my $username = 'yourgmailid';
my $password = 'yourpasswrd';
my $mech = WWW::Mechanize->new();
$mech->cookie_jar(HTTP::Cookies->new());
$mech->get($url);
$mech->form_id('gaia_loginform');
$mech->field("Email", $username);
$mech->field("Passwd", $password);
$mech->click;
my $output_page = $mech->content();
print $output_page;
open(OUTFILE, ">$outfile");
binmode(OUTFILE, ":utf8");
print OUTFILE "$output_page";
close(OUTFILE);
I also used print $output_page; to check the contents separately, you can ignore that one. | [reply] [Watch: Dir/Any] [d/l] |
|
Hi,
I have used this script, its working fine. But I have one doubt that If particular System is slow in that case also this will work? or we need to do any changes in script. Please reply. Thanks
| [reply] [Watch: Dir/Any] |
|
can u please share u script in the reply.. because the above is not working properly
| [reply] [Watch: Dir/Any] |
|
|
|
Hi, Many thanks for your help, now I am able to login to Gmail and my another secure website, on which again I was using wrong Form details...
Much appreciate your help on this :)
Now I am trying to go the link which I get after login.. Plz let me know if follow_link(text => 'string') will work on this or do I need to use any other function...
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] |
|
|
use strict;
use warnings;
use strict;
use WWW::Mechanize;
use HTTP::Cookies;
my $outfile = "out2.htm";
my $url = "https://accounts.google.com/ServiceLogin?service=mail&passi
+ve=true&rm=false&continue=http://mail.google.com/mail/&scc=1<mpl=de
+fault<mplcache=2";
my $username = 'yourgmailid';
my $password = 'yourpasswrd';
my $mech = WWW::Mechanize->new();
$mech->cookie_jar(HTTP::Cookies->new());
$mech->get($url);
$mech->form_id('gaia_loginform');
$mech->field("Email", $username);
$mech->field("Passwd", $password);
$mech->click;
my $output_page = $mech->content();
print $output_page;
open(OUTFILE, ">$outfile");
binmode(OUTFILE, ":utf8");
print OUTFILE "$output_page";
close(OUTFILE);
-----------------------------------------------------------
Very thanks for the above script.
After once logged in to the gmail I would like display output like "Log in successful", if log in fails I would like to display "Log in fail";
Please help me on the above condition.
Thanks, you
Jineesh.K
| [reply] [Watch: Dir/Any] [d/l] |
|
|
|
|
Hi,
I want to export/download the containt/data through CSV file from a https: site.
Can you please suggest me a script and also suggest me how to run it, as I am a biginer for perl.
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] |
|
when i am executing the above code, i am getting a error generated as : Can't locate WWW/Mechanize.pm in @INC (@INC contains: /usr/local/lib64/perl5 /us /perl5 /usr/share/perl5 .) at login.pl line 4.
BEGIN failed--compilation aborted at login.pl line 4.
can u pls resolve the issue asap..
| [reply] [Watch: Dir/Any] |
|
cpan WWW::Mechanize
Update: See also Tutorials->Installing Modules. | [reply] [Watch: Dir/Any] [d/l] |
A reply falls below the community's threshold of quality. You may see it by logging in.
|
Re: Perl Script to login to a secure WebSite
by Anonymous Monk on Aug 03, 2012 at 00:06 UTC
|
| [reply] [Watch: Dir/Any] |
|
thanks for replying...
Acutally my requirement is, I need to login to one of my secure website with username & password. After that I need to get some data from one more link in the next page.. So I need general code to login to secure website as Mail::Webmail::Gmail is only for GMAIL..
I will check on POP3, as of now I am not sure on this..
| [reply] [Watch: Dir/Any] |
|
When i am running yua code. there is a error which i generated as :
Error: Can't locate object method "new" via package "Mail::Webmail::Gmail" (perhaps you forgot to load "Mail::Webmail::Gmail"?) at login1.pl line 4. Can u try to resolve the issue.. and come up with the new code..
What does it mean??
| [reply] [Watch: Dir/Any] |
|
The parent post does not mention Mail::Webmail::Gmail at all, so you are not running the code you are replying to.
Note that the bug reports for Mail::Webmail::Gmail show that it has not been maintained since 2006, which makes it quite unlikely for a web scraper to still work.
If you want to continue with the code you have, you will have to install Mail::Webmail::Gmail. Either use your OSes package manager to install the module or install it through the cpan tool:
cpan Mail::Webmail::Gmail
Most likely, you will find it much easier to acces Gmail through IMAP. | [reply] [Watch: Dir/Any] [d/l] [select] |
|
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] |
Re: Perl Script to login to a secure WebSite
by linuxkid (Sexton) on Aug 03, 2012 at 01:16 UTC
|
if you know the names of the fields, try using LWP::UserAgent, and the post(); function.
--linuxkid
imrunningoutofideas.co.cc
| [reply] [Watch: Dir/Any] [d/l] |