in reply to Re: Handling Javascript with LWP::UserAgent
in thread Handling Javascript with LWP::UserAgent

Hi. This is an example of a page I retrieved that uses JavaScript. The code is as so:
#!/usr/bin/perl use strict; use LWP::UserAgent; { my $ua = new LWP::UserAgent(); my $search_address = "http://online.wsj.com/search/full.html?"; #creating the request object my $req = new HTTP::Request ('GET', $search_address); #sending the request my $res = $ua->request($req); if (!($res->is_success)){ warn "Warning:".$res->message."\n"; } my $response = $res->headers_as_string(); my $response .= $res->content(); print "$response\n"; }
If you run this code you should get a response that has Javascripts. As you can see the code is basically the same except for the URL.

Replies are listed 'Best First'.
Re^3: Handling Javascript with LWP::UserAgent
by Joost (Canon) on Jul 09, 2006 at 16:25 UTC
Re^3: Handling Javascript with LWP::UserAgent
by Ieronim (Friar) on Jul 09, 2006 at 16:30 UTC
    The JavaScript on the page can do many different things. In some cases javascripting can be ignored, in some cases cannot.

    In general, if you can work with the page with Javascript turned off in your favorite browser without any loss of essential functionality — you can easily work with the page using LWP::UserAgent.