Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Parsing HTML tags with regex

by davorg (Chancellor)
on Oct 03, 2002 at 13:23 UTC ( [id://202503]=note: print w/replies, xml ) Need Help??


in reply to Parsing HTML tags with regex

I know you don't want to use HTML::foo (tho' you never explain why) but in the interests of having at least one "best practices" answer listed here an HTML::TreeBuilder solution is given below:

#!/usr/bin/perl use warnings; use strict; use LWP::Simple; use HTML::TreeBuilder; my $page = get ('http://pvpgnservers.ath.cx/') or die; my $tree = HTML::TreeBuilder->new; $tree->parse($page); my @trs = $tree->find_by_tag_name('tr'); my @stuff; foreach my $row (@trs) { if ($row->as_text =~ /^217\.172\.178\.113/) { @stuff = map { ref $_ ? $_->as_text : $_ } $row->content_list; last; } } print "@stuff\n";
--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re: Re: Parsing HTML tags with regex
by Chmrr (Vicar) on Oct 03, 2002 at 13:33 UTC

    See also this other node in the other thread; I take a slightly different approach to the problem, but also using HTML::TreeBuilder. TIMTOWTDI, indeed.

    perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://202503]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-12-08 10:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which IDE have you been most impressed by?













    Results (50 votes). Check out past polls.