in reply to Please help with a fetching issue
Either of these (tuned to your need) should do the trick. HTML::TokeParser::Simple or XML::LibXML.
use LWP::Simple qw( get ); use HTML::TokeParser::Simple; my $page = get(+shift || die "Gimme URI!\n"); my $p = HTML::TokeParser::Simple->new(\$page); while ( my $token = $p->get_tag("td") ) { next unless $token->get_attr("class") =~ /\bsomeClass\b/; my $first_child = $p->get_token(); print $first_child->as_is, $/; last; } use XML::LibXML; my $p = XML::LibXML->new; $p->recover_silently(1); my $doc = $p->parse_html_string($page); my ( $td ) = $doc->findnodes('//td[@class="someClass"]'); print $td->textContent, $/;
(update: rolled into single <code/> and fixed tag name.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Please help with a fetching issue
by mahira (Acolyte) on Mar 25, 2010 at 06:50 UTC |