Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Perl simple login script need pls help

by Scrilla (Initiate)
on Feb 24, 2014 at 22:18 UTC ( #1076041=perlquestion: print w/replies, xml ) Need Help??

Scrilla has asked for the wisdom of the Perl Monks concerning the following question:

Hello :) i will write a Perl script for my Debian Server. This script target the login to this site: Here is my code:
#!/usr/bin/perl use CGI; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use Crypt::SSLeay; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); my $url = ""; $mech->agent('User-Agent=Mozilla/5.0 (Macintosh; U; Intel Mac OS X + 10.5; en-US; rv: Gecko/20091102 Firefox/3.5.7'); $mech->get($url); print $mech->status; $result = $mech->submit_form( form_id => new_user, #name of the form #instead of form name you can specify #form_number => 1 fields => { user_login => 'test', # name of the input field and value user_password => 'test', } ,button => 'commit' #name of the submit button ); my $app_content = $mech->content(); print "$app_content\n";
I think it not works, because the "print" is the standard content. I hope anywhere can help me. Sorry for my bad english, thank you very much.

Replies are listed 'Best First'.
Re: Perl simple login script need pls help
by stonecolddevin (Parson) on Feb 24, 2014 at 22:33 UTC

    Read up on the documentation on how to see what the server has sent back, specifically ->response. You could either print or use Data::Dumper to display the response/response object and see if your requests are actually succeeding or not.

    Three thousand years of beautiful tradition, from Moses to Sandy Koufax, you're god damn right I'm living in the fucking past

Re: Perl simple login script need pls help
by Gangabass (Vicar) on Feb 25, 2014 at 02:54 UTC

    You need

    $mech->submit_form( with_fields => { 'user[login]' => 'test', 'user[password]' => 'test', }, button => 'commit', );

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1076041]
Approved by Old_Gray_Bear
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2020-07-02 10:15 GMT
Find Nodes?
    Voting Booth?

    No recent polls found