Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Can you help a french user ?

by ynnvlz (Initiate)
on Apr 07, 2013 at 11:39 UTC ( [id://1027356]=perlquestion: print w/replies, xml ) Need Help??

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

Hello, I'm a new franch user of perlmonks.org and I want to test the reactivity of users ! :D I have a problem with a login script. I want to connect the 178.33.132.12 and log to my user account with a webbot in perl But I don't understand with the method. There is my code :

#!/usr/bin/perl -w use strict; use LWP::UserAgent; use HTML::Form; use HTTP::Cookies; # initialisation de l'agent my $ua = LWP::UserAgent->new( agent => 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:19.0) +Gecko/20100101 Firefox/19.0', cookie_jar => HTTP::Cookies->new( file => 'LWPcookies.txt', autosave => 1, ignore_discard => 1, ) ); # initialisation de la requete my $base = 'http://178.33.132.12/'; my $res = $ua->request(HTTP::Request->new( GET => $base )); my $form = HTML::Form->parse($res->decoded_content, base => $res->base, charset => $res->content_charset, ); # afficher le Infolog my $infolog = $form->find_input('infolog')->value; print($infolog); # se logger my $user = 'LOGIN'; my $pass = 'PASSWORD'; my $loginlink = 'http://178.33.132.12/index.php?infolog=' . $infol +og . '&Login=' . $user . '&password=' . $pass . '&btn_login.x=66&btn_ +login.y=17'; $ua->request(HTTP::Request->new( GET => $loginlink ));

I'm sorry if I don't use convenience usage of perlmonks, I'm a beginner forum user. :s Please can you help me ?

Replies are listed 'Best First'.
Re: Can you help a french user ?
by marto (Cardinal) on Apr 07, 2013 at 12:47 UTC

    Firstly ensure you're not in violation of the terms of service by automating this, since I can't find any (I don't have an account) I've no idea what they are. I suggest you contact them to be sure. The site seems to depend hevily on JavaScript so you're going to have to use something which understands JavaScript. WWW::Mechanize makes automating web interfaces fairly simple, but it doesn't deal with JavaScript, WWW::Mechanize::Firefox allows you to automate Firefox in this manner.

    If your goal is to automate a Flash based online game I think you're going to have lots of problems.

Re: Can you help a french user ?
by Gangabass (Vicar) on Apr 07, 2013 at 14:27 UTC
    As I see you need to POST instead of GET.

    And remember Life is short so use WWW::Mechanize; It will automatically work with cookies for you, process forms, links etc.

    use WWW::Mechanize; my $mech = WWW::Mechanize->new(); $mech->agent_alias("Windows IE 6"); $mech->get($base); $mech->submit_form( with_fields => { login => $user, password => $pass, 'btn_login.x' => 66, 'btn_login.y' => 17, }, );

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1027356]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-03-29 07:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found