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

Hi monks, I am learning on how to use www::mechanize for web automation. I tried the following code for paypal, and it did let me logged in succesfully.
use WWW::Mechanize; my $mech = WWW::Mechanize->new(); $mech->get('https://www.paypal.com/us'); $mech->submit_form( form_number => 1, fields => { login_email => 'sss', login_password => 'sss', } ); die unless ($mech->success); print $mech->content();
However, I tried to use this same code for another https, but this site won't let me in because $mech->content still outputs the login page. Would you please kindly advise me what might go wrong? Thank you.

Retitled by g0n from 'www::mechanize'.

Replies are listed 'Best First'.
Re: Validating using WWW::Mechanize
by monarch (Priest) on Aug 03, 2005 at 00:51 UTC
    Your code worked for paypal. However not all websites are like paypal.

    If you try and log into "SiteB", then carefully look at the HTML source of the "SiteB" log-in page. Is it using javascript? Does it require a different button to be pressed?

    There is no easy answer to your question. But the good news is you figured out paypal.. which means you can probably figure out "SiteB".

Re: Validating using WWW::Mechanize
by gube (Parson) on Aug 03, 2005 at 01:17 UTC

    Code u have used is correct. You just check out the form_number in some site there may be number form_number 2 or 3. For eg. https://adwards.gooogle.com they used 3 form_number upto 3. print the content after the $mech->get and check what your getting. From there you can verify the number of forms they used.

    It will work if than if email and password is correct. May be you send the javascriptEnabled => True. Bcoz. in https site they may check these also. For eg. in adwards.google.com they check.

    Before you get the content u login manually with username and password and see the script condition based what they entering and pass the key and value with in the submit_form.

      The solution to my problem is for me to explicitly mention the button in submit_form, while in Paypal I don't have to do that.
      Strange...
      Thank you for your assistance guys!!!