in reply to Perl HTML confusion...
use HTML::TreeBuilder; my $tree = HTML::TreeBuilder->new_from_file('test.html'); my @divs = $tree->look_down(_tag => 'div'); print $divs[0]->as_text();
I saved this node to test.html, and so it outputs your first post.
Output:
I'm having trouble with using Perl to parse an HTML file I have, where I'm trying to grab all <a>...I'm not going to repost it all, but the full text of your first post is there.
When you want to match regular expressions you have to pass a sub ref to look_down. There is an example in HTML::Element. Also, here is a quick intro: HTML::Tree(Builder) in 6 minutes. And a more thorough article: HTML::Tree::Scanning
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl HTML confusion...
by AI Cowboy (Beadle) on Sep 17, 2013 at 22:29 UTC |