in reply to Re: Parsing HTML
in thread Parsing HTML
This, of coarse is not much different from the above code. I just dont understand this HTML stuff, and cant seem to find any pages to really help. I want to Take out the text contained in href when the text is Level III and put it into a variable. Is href a node, namespace, or what?#!/usr/bin/perl -w use strict; use HTTP::Lite; use HTML::TreeBuilder; my $http = new HTTP::Lite; my $req = $http->request("http://has.ncdc.noaa.gov/pls/plhas/has.dssel +ect") or die "Unable to get document: $!"; die "Request failed ($req): ".$http->status_message() if $req ne "200" +; my $body = $http->body(); my $t = HTML::TreeBuilder->new_from_content($body) or die qq{cant buil +d tree: $!\n}; my @anchors = $t->look_down(_tag => q{a}); for my $anchor (@anchors){ if ($anchor->as_text eq q{NEXRAD Level III}){ $anchor->replace_with_content; } } print $t->as_HTML( undef, q{ }, {}, ); $t->delete;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Parsing HTML
by wfsp (Abbot) on Jun 16, 2009 at 17:57 UTC |