Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Merging two anchors with HTML::TreeBuilder

by Anonymous Monk
on May 10, 2016 at 06:26 UTC ( [id://1162594]=note: print w/replies, xml ) Need Help??


in reply to Re: Merging two anchors with HTML::TreeBuilder
in thread Merging two anchors with HTML::TreeBuilder

HTML::TreeBuilder::XPath with htmltreexpather.pl makes it easier to find what you want, like the second link in each tablecell
use HTML::TreeBuilder::XPath; #~ my $root = HTML::TreeBuilder->new; my $root = HTML::TreeBuilder::XPath->new; for my $secondlink ( $root->findnodes( '//td/a[2]' ) ){ my $td = $secondlink->parent; my $newtext = $td->as_trimmed_text ; $secondlink->delete_content; $secondlink->push_content( $newtext ) ; $secondlink->detach; $td->delete_content; $td->push_content( $secondlink ); }

Replies are listed 'Best First'.
Re^3: Merging two anchors with HTML::TreeBuilder
by mldvx4 (Friar) on May 10, 2016 at 19:29 UTC

    Thanks, both. I've gone with the HTML::TreeBuilder::XPath option.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-25 20:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found