Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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: + Gecko/201 00401'); $mech->use_plugin(JavaScript => engine => 'JE', ); $mech->get(""); 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

Replies are listed 'Best First'.
Re: Login Website
by thomas895 (Chaplain) 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).


    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?

      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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://966180]
Approved by marto
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2018-07-18 22:34 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (397 votes). Check out past polls.