Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Perl Script to login to a secure WebSite

by Anonymous Monk
on Jun 26, 2013 at 11:20 UTC ( #1040753=note: print w/replies, xml ) Need Help??


in reply to Re^2: Perl Script to login to a secure WebSite
in thread Perl Script to login to a secure WebSite

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&ltmpl=de +fault&ltmplcache=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

Replies are listed 'Best First'.
Re^4: Perl Script to login to a secure WebSite
by Anonymous Monk on Oct 22, 2016 at 12:14 UTC
    The code is executing well but the output which we are getting is in the html format , cannot we get the output in the gui , so that if at all we run the script the gmail account of ours will be automatically logged in,,??

      If you want to automate the login into gmail and then continue the session in a browser, you will either have to automate a browser, like Win32::IEAutomation or WWW::Mechanize::Firefox provides or you'll have to store the appropriate session variables in the cookies of the browser. There are various HTTP::Cookies modules that allow reading and writing the cookies of a browser.

        Even though i have used the Win32::IEAutomation before the perl script, the output which is generated in the html format , its not getting login in the gmail authentication page.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1040753]
help
Chatterbox?
[marto]: Milwaukee
[1nickt]: thx marto
[LanX]: Canada?
[MidLifeXis]: :-)
[MidLifeXis]: Not for a few years yet. Kids in school :-)
[LanX]: NQC
[MidLifeXis]: Is there internet access up there on the lakes? If I moved there I would like to be able to fish :-D
[LanX]: Not Quite Canada
[Discipulus]: have you been fired?!?
[LanX]: remote rules, I've been offered jobs in the US with the promise to stay outside

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (12)
As of 2017-03-23 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (286 votes). Check out past polls.