Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Perl Script to login to a secure WebSite

by ckj (Chaplain)
on Aug 03, 2012 at 06:28 UTC ( #985162=note: print w/ replies, xml ) Need Help??


in reply to Perl Script to login to a secure WebSite

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&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);
I also used print $output_page; to check the contents separately, you can ignore that one.


Comment on Re: Perl Script to login to a secure WebSite
Download Code
Replies are listed 'Best First'.
Re^2: Perl Script to login to a secure WebSite
by Anonymous Monk on Apr 22, 2013 at 06:25 UTC
    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
Re^2: Perl Script to login to a secure WebSite
by Anonymous Monk on Aug 06, 2012 at 01:24 UTC
    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...

      Plz let me know if follow_link(text => 'string') will work on this or do I need to use any other function...

      What happens when you T.I.T.S - Try It To See ?

        Hi, After logging to the website, I am able to go the one more link in the next page. Now I have to select the checkbox which enables few buttons (after selecting the checkbox). Once button is enabled I need to click one of the button, which opens one form, I need to select one value from the drop down and submit. Once this completes then I am done with all my steps.. Please suggest on this, here that site uses internally Java Script.. I tried to seclect checkbox, then button and then submit.. Script runs fine without any error but action is not performing... :( Plz correct me if any wrong in the code..
        $mech->tick( 'D:_ctl2:_ctl0', 'on'); #$mech->tick( "D:_ctl2:_ctl0" ); print $mech->success(); $mech->current_form()->find_input(undef, 'Assign'); print $mech->success(); $mech->field('K', 'Name1'); print $mech->success(); $mech->current_form()->find_input(undef, 'Update'); print $mech->success();
      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
Re^2: Perl Script to login to a secure WebSite
by Panigrahi on Dec 30, 2013 at 12:39 UTC
    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://985162]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2015-07-30 00:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls