develooper Front page | perl.libwww | Postings from January 2001

help parsing HTML code

Thread Next
From:
Andy Farrior
Date:
January 31, 2001 10:46
Subject:
help parsing HTML code
Message ID:
5.0.2.1.0.20010131123456.02488dd0@vc.cc.tx.us
Greetings,

I'm trying to read the following HTML code:

<input type="text" size="10" name="video_fec_errors_rx" value="24" READONLY>

I need to extract the value for video_fec_errors_rx.  I can't seem to 
figure out how to do it.  (This is the first time I've tried to use the LWP 
library.)

The web server I'm connecting to uses one form to display various values.

I think I need to use the HTML::Parse or HTML::TreeBuilder modules, but I 
get stuck really quick.

I know this a newbie question; so please be kind.

Thanks,
Andy

#!/usr/bin/perl
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$ua->agent("AgentName/0.1 " . $ua->agent);

[snip]

$URL = "http://$USERID:$PASSWORD\@$HOST/a_advannetstat.htm";

my $req = new HTTP::Request GET => $URL;
my $res = $ua->request($req);

if ($res->is_success) {
     $content = $res->content;
     print "$content\n";
} else {
     print "Can't reach $HOST\n";
}


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About