in reply to Browser Emulation

This is a pretty simple-minded example how you might do this using LWP::UserAgent and HTML::Parser:

#!/usr/bin/perl -w use strict; use LWP::UserAgent; use HTML::Parser; use URI; my $starturl = shift || die "No url supplied\n"; my $baseuri = URI->new($starturl); my @urls ; push @urls,$starturl; my $agent = new LWP::UserAgent; my $parser = HTML::Parser->new(api_version => 3, start_h => [\&start ,"tagname, attr"]); $agent->agent("Gelzilla/666"); while( my $url = shift @urls) { my $request = new HTTP::Request 'GET' => $url; my $result = $agent->request($request); if ($result->is_success) { print $result->as_string; $parser->parse($result->content); } else { print "Error: " . $result->status_line . "\n"; } } sub start { my($tag,$attr) = @_; if ($tag eq 'frame' ) { my $thisuri = URI->new($attr->{src}); push @urls, $thisuri->abs($baseuri); } }

Of course you are going to have to make your own arrangements for displaying things properly :)

/J\

Replies are listed 'Best First'.
Re: Re: Browser Emulation
by jonjacobmoon (Pilgrim) on Feb 03, 2002 at 17:34 UTC
    Wow, that was way too easy :)

    Major ++ for that. I was expecting a partial answer but you pushed it nearly all the way to the end. This is very close to what I wanted. I have to do more tests to see if it will handle all possible cases (or at least as many as I can come with), but it looks like a great solution.

    Thanks.


    I admit it, I am Paco.