Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^5: Ignoring specific html tags before parsing

by Anonymous Monk
on Oct 08, 2013 at 02:21 UTC ( [id://1057340]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Ignoring specific html tags before parsing
in thread Ignoring specific html tags before parsing

#!/usr/bin/perl -- use strict; use warnings; use XML::LibXML 1.70; ## for load_html/load_xml/location Main( @ARGV ); exit( 0 ); sub Main { my $loc = shift or die " Usage: $0 ko00010.html $0 http://example.com/ko00010.html\n\n"; my $dom = XML::LibXML->new( qw/ recover 2 / )->load_html( location => $loc, ); for my $node ( $dom->findnodes( '//table | //img | // script | // +style | //noscript ' ) ){ $node->detach; } print $dom->find('//body')->[0]->textContent,"\n"; } sub XML::LibXML::Node::detach { my( $self ) = @_; $self->paren +tNode->removeChild( $self ); }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-25 22:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found