Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw


by shockme (Chaplain)
on Dec 09, 2003 at 18:04 UTC ( #313467=perlquestion: print w/replies, xml ) Need Help??

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

I think I'm missing something fairly basic. I'm trying to access a website which requires frames. Following is my script:
#!/usr/bin/perl use strict; use warnings; use URI::URL; use LWP::UserAgent::FramesReady; my $ua = new LWP::UserAgent; # neither of the following have any effect #$ua->agent('Mozilla/5.0'); #$ua->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET C +LR 1.1.4322)'); my $url = URI->new(''); my $http_request = new HTTP::Request('GET', $url); my $response = $ua->request($http_request); if ($response->is_success and $response->isa('HTTP::Response::Tree')) { print "ok\n"; } else { print $response->content; } exit;
This results in the following output:
<HTML> <HEAD> <meta name="DESCRIPTION" content=""> <TITLE></TITLE> </HEAD> <!-- Redirection Services Redirector2B-DAL 200-OK --> <FRAMESET ROWS="100%, *" frameborder="no" framespacing=0 border=0> <FRAME SRC="" NAME="mainwindow" frameb +order="no" framespacing="0" marginheight="0" marginwidth="0"></FRAME> </FRAMESET> <NOFRAMES> <CENTER> <H2> Your browser does not support frames. We recommend upgrading your + browser. </H2> <br><br> Click <a href="">here</a> to enter th +e site. </CENTER> </NOFRAMES> </HTML>

I've dug through several of the test scripts included with LWP::UserAgent::FramesReady, but I'm just not seeing what I'm missing.

If things get any worse, I'll have to ask you to stop helping me.

Replies are listed 'Best First'.
Re: LWP::UserAgent::FramesReady;
by holo (Monk) on Dec 09, 2003 at 18:24 UTC

    First of all, you should use LWP::UserAgent::FramesReady not LWP::UserAgent to construct the $ua.

    my $ua = new LWP::UserAgent::FramesReady;

    The result is not an HTTP::Response instance, rather a more appropriate HTTP::Response::Tree object since more than one page is fetched (The main page, the frames, sub-frames, etc...). It's pretty straight forward to get all the responses out with @responses = $response_tree->children();.

      Wow. I guess the documentation is wrong:
      SYNOPSIS use LWP::UserAgent::FramesReady; $ua = new LWP::UserAgent; $response = $ua->request($http_request);

      But you are correct. It's working great now. Thanks!

      If things get any worse, I'll have to ask you to stop helping me.

        Please consider submitting a documentation patch, or at least letting Alan E Derhaag know about this.

        ciao ciao!

        zz zZ Z Z #!perl

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://313467]
Approved by barbie
Front-paged by tye
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2020-10-23 02:42 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (234 votes). Check out past polls.