Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Login Website

by crazy5655 (Initiate)
on Apr 20, 2012 at 11:38 UTC ( #966180=perlquestion: print w/ replies, xml ) Need Help??
crazy5655 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I have a problem to login a wbsite which calls javascript, I read docs where they suggested to use WWW::Scripter. But no luck. Look into my code and source of website. and suggest me the best way to resolve this issue.
my $mech = WWW::Scripter->new(); $mech->agent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en; rv:1.9.2.3) + Gecko/201 00401'); $mech->use_plugin(JavaScript => engine => 'JE', ); $mech->get("https://www.mywesite.com/plp/login.do"); print $mech->content; $mech->submit_form( with_fields => { userId => 'myId', pass => 'myPass +' } );
Here my submit button calls a Jscript function called submitLoginForm; Submit :
--<td class="submitButton" id="SignInButton"> <a href="#" onclick='return submit +LoginForm("ACTION_PIN_LOGIN","myLogin");'>
Here the function details
function submitLoginForm(val,source) { if(val == "ACTION_PIN_LOGIN") removeSignInButton(); document.forms['LoginForm'].action.value = val; document.forms['LoginForm'].source.value = source; document.forms['LoginForm'].submit(); return false; }
help me to resolve this issue

Thanks in Advance

Comment on Login Website
Select or Download Code
Re: Login Website
by thomas895 (Hermit) on Apr 20, 2012 at 13:24 UTC

    And this is why I hate letting everyone use HTML as they please on here.
    OP: You're going to have to escape that HTML or find another way to show it to us(e.g., a pastebin).

    Update(20apr2012):

    Now that I can read this properly(thanks guys), I might be able to help you. But first you will have to tell us: what was the expected result? What actually happened? What other things have you tried, and what was their result?

    ~Thomas~
      Not able to login, it displays the home page content only when I print mech-content. I want to login and print the target content.
Re: Login Website
by Riales (Hermit) on Apr 20, 2012 at 17:36 UTC
    You could try triggering the site's own submitLoginForm function with trigger_event:
    # This won't work exactly, but it's a hint: $w->document->links->[0]->trigger_event('onclick');
      No luck, can anybody suggest

        Well, are you married to the idea of using WWW::Scripter? I've had a great deal of success using WWW::Selenium for automating javascript-heavy web pages. Might be worth looking into?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2014-08-29 10:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (280 votes), past polls