Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^7: Looking for a module that strips an HTML tag and its associated 'TEXT'

by marto (Cardinal)
on Jul 29, 2020 at 14:29 UTC ( #11119980=note: print w/replies, xml ) Need Help??


in reply to Re^6: Looking for a module that strips an HTML tag and its associated 'TEXT'
in thread Looking for a module that strips an HTML tag and its associated 'TEXT'

And did you look at my earlier suggestion?

  • Comment on Re^7: Looking for a module that strips an HTML tag and its associated 'TEXT'

Replies are listed 'Best First'.
Re^8: Looking for a module that strips an HTML tag and its associated 'TEXT'
by nysus (Parson) on Jul 29, 2020 at 14:40 UTC

    I looked at Mojo::Dom briefly. It's a general purpose tool. Was hoping for a module that let me knock this out in in like two lines. Mojo::Dom is my fallback plan if I can't find what I'm looking for.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

      "Was hoping for a module that let me knock this out in in like two lines."

      Ignoring this many dependant modules and literally thousands of lines of code :P

      my $html = 'url: <a href="http://example.com">http://example.com</a>'; my $dom = Mojo::DOM->new( $html ); say $dom->at('a')->remove;

        Almost, not quite. Need this:

        # strips a specific tag from string sub eliminate_tags { my ($page, $tag) = @_; my $dom = Mojo::DOM->new; foreach my $b ($dom->parse($page)->find($tag)->each) { $b->remove } return $dom; }

        So my beef it that: 1) I'd have to be familiar enough with Mojo::Dom to figure out it could do this (I'm not) so I needed to come PerlMonks to find someone like you to help and 2) I have to spend 20 min. wading through monstrous documentation to figure out how to use it for something simple.

        So why isn't a specific tool better than a general purpose tool? You're saying a specific tool is inferior because it has more dependencies?

        $PM = "Perl Monk's";
        $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
        $nysus = $PM . ' ' . $MCF;
        Click here if you love Perl Monks

        Would it make sense, in your opinion, to create new module that is just a wrapper for Mojo::DOM with a specific use case of deleting nodes with a certain tag and submitting to cpan?

        $PM = "Perl Monk's";
        $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
        $nysus = $PM . ' ' . $MCF;
        Click here if you love Perl Monks

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2021-11-28 12:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?