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

Hi,

I have a webpage that I want to dump the source HTML for. The page appears to be rendered from extra execution of JavaScript functions, so I cannot use WWW::Mechanize to get the content because it requires further JavaScript execution. So, I've tried

Win32::IE::Mechanize

But I am still getting source that has unexecuted JavaScript in it ( for instance, I get one page that has a 'window.location( ... )' function in the text returned by my IE::Mechanize code, but it itself is not executed.

However, IE done interactively renders this as I expect it to.

My question is: how can I get this to finish rendering the page and get the output of that source? Interactively, once it renders and I ask for the source, it has the content I want.

PS -- Just so you know, I'm using IE rather than Firefox/Chrome/Whatever because the pages I am parsing are from an internal (3rd party) app that requires NTLM authentication, and my IE is configured to pass that along quite well ( but I see I can specify my creds in IE::Mechanize as well).

Any help is appreciated,
Matt

Nodes I've looked at: http://perlmonks.org/?node_id=807938

Code I've used:
use Win32::IE::Mechanize; my $url = 'https://myrurl/mypage/'; my $ie = Win32::IE::Mechanize->new( visible => 0 ); $ie->credentials('myrurl:80', '', "TLR\\unnnnnnn", 'xxxxxxxx'); $ie->get( $url ); print $ie->content, "\n"; $ie->close;

Replies are listed 'Best First'.
Re: Getting InternetExplorer Source after JavaScript Executes
by Anonymous Monk on May 18, 2010 at 02:50 UTC