Re: help parsing HTML code
gil cohen (cohengil4@hotmail.com)
Wed, 31 Jan 2001 15:01:53 -0500
You don't any of that weird stuff. All you need is a simple regex. In that
$res->is_sucess if, put something like:
$content =~ m/<input type=\"text\" size=\"10\" name=\"video_fec_errors_rx\"
value=\"(.*?)\" READONLY>/;
$value = $1;
and now $value has what value is equal to.
>From: Andy Farrior <afarrior@vc.cc.tx.us>
>To: libwww@perl.org
>Subject: help parsing HTML code
>Date: Wed, 31 Jan 2001 12:46:21 -0600
>
>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";
>}
>
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com