Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Using www::Mechanize

by ItsyBitsy (Novice)
on May 17, 2012 at 03:37 UTC ( #970968=perlquestion: print w/ replies, xml ) Need Help??
ItsyBitsy has asked for the wisdom of the Perl Monks concerning the following question:

Hi guys,

I am using WWW::Mechanize to automate a script on the amazon page. However i am not even able to sign into the page using WWW::Mechanize. The url link. is where the form is. How would i use mechanize to log into this page.

My code:
use WWW::Mechanize; my $mech = WWW::Mechanize->new(); $mech->get("https://www.amazon.com/gp/css/homepage.html/"); $mech->submit_form( form_name => 'yaSignIn', fields => { 'email' => $email, 'password' => $password, }, ); print $mech->content();
The output of mech dump is as follows.
POST https://www.amazon.com/gp/flex/sign-in/select.html [yaSignIn] useRedirectOnSuccess=1 (hidden readonly) path=/gp/css/homepage.html (hidden readonly) action=sign-in (hidden readonly) protocol=https (hidden readonly) email= (text) password= (password) <NONAME>=Sign In (submit)
The html for sumbitting a form
<input width="201" type="image" height="22" border="0" align="absmiddl +e" id="submit" value="Continue" alt="sign in using our secure server" + src="https://images-na.ssl-images-amazon.com/images/G/01/x-locale/co +mmon/buttons/sign-in-secure._V192194766_.gif">
When i save the output to file it says please enable cookies to continue.

Comment on Using www::Mechanize
Select or Download Code
Re: Using www::Mechanize
by stevieb (Chaplain) on May 17, 2012 at 04:01 UTC

    The care you put into your post is going to be equivalent to the love contained within the responses you get.

    The time you took to create this post and not do any editing at all is embarrassing at best. You want help, but yet you don't care at all what you're presenting.

    At *minimum*, where's your code that you've tried?

      Sorry about that. Have edited the question now.
Re: Using www::Mechanize
by stevieb (Chaplain) on May 17, 2012 at 04:33 UTC

    I'd like to rephrase my last reply without taking anything away from it...

    This is a place where many significant Perl coders hang out. I assume many of them review and post on this site while at work (regardless of what their day job is), and also while at home. I'm but a humble intermediary coder (depending on the context), but I sometimes let my emotions wreak havoc.

    It bothers me when I see poorly presented questions, as I'm learning how much it frustrates other monks who have better things to do. I used to get upset with terse responses. Now I'm starting to understand.

    To the OP: You might not have read How do I post a question effectively?, but it isn't fair to assume that this is just some one-off PHP forum you're in either.

    /rant

      Kudos to ItsyBitsy for cleaning up the post.

      I'm sorry for my rant.

      Update: unfortunately, most won't see what my rant was about as the original was edited. Either way, it is what it is, and OP stepped up to the plate and did what was right.

        Finally got it. I had to add an agent alias. It was answered on stack overflow- link here.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2014-12-21 16:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (106 votes), past polls