Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Here are some more links with LWP info.. read this one and look at Planetscape's reply to my post with more online books.. Re: Perl code to check and count count if a word exists on a webpage.

Perl cannot run Javascript, but most of the time you don't need to do that. Basically with the various LWP techniques and modules, you are emulating a browser. Figure out what needs to go into the "post" back to the server and just stick the password in there. The webserver has no way to tell whether or not you actually executed some Javascript code - it just looks at what is posted back to it. Usually with some experimentation (sometimes with LOTS of experimentation), I can figure this out by looking at the source code to the webpage.

Update: When you update a post, add some kind of tag like this so that we can tell that something new has been added. I would stay away from WWW::Mechanize::Firefox unless you really need it. This thing is pretty cool and I've done some experimentation with it, but this introduces another layer of complexity into the implementation.

Another Update:
I looked back at one of my LWP programs.

(1) You are emulating a browser. You can claim to be different versions or types of browsers. I find it helpful to claim to be the "stupidest thing" that the website will allow. Many websites serve up different pages depending upon who you are claiming to be - dumber browsers get different pages than smarter browsers. Below I am claiming to be an ancient version of Netscape.

(2) Often it is not necessary to even parse what the server sends you. Below I just checked that I got a valid page (no 404 error or whatever), and then I immediately just post back my credentials. I know that this is the log-in page.

(3) In the post(), I send what I need to. Figuring out what should go into the post() is where the looking at the webpage source and experimentation comes in. The server has no way to figure out what (if any) Javascript code I ran or didn't run.

my $ua = LWP::UserAgent->new or die "Problem with the new UserAgent\n" +; $ua->cookie_jar(HTTP::Cookies->new); $ua->agent("Mozilla/4.76 [en] (Windows NT 5.0; U)"); print "And now I'm calling myself ", $ua->agent( ), "!\n"; # # Get the log on page to the Secure Server # my $response = $ua->get($url) or die "Problem with the get $url\n"; $response->is_success or die "Failed to GET '$url': ", $response->status_line; my $html_page = $response->content( ); # # post the secure log-on with my credentials # $response = $ua->post( 'https://services....someurl', [ 'type' => "ABCDEF", #weird parameters that are page specific "prev" => "GHIJK", 'p201' => "XYZZY", 'p1' => 'some_user_name', 'p2' => 'some_domain', 'p3' => 'some_password' ], );
Of course as with all of these things, mileage varies.

In reply to Re: Need to fill password in with perl on Javascript? by Marshall
in thread Need to fill password in with perl on Javascript? by jdlev

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (9)
    As of 2018-10-19 19:25 GMT
    Find Nodes?
      Voting Booth?
      When I need money for a bigger acquisition, I usually ...

      Results (110 votes). Check out past polls.