How to use HTML::Parser to remove HTML tags and print result

Discussion in 'Perl' started by Mitchua, Jul 14, 2003.

  1. Mitchua

    Mitchua Guest

    I am trying to use HTML::parser to parse an HTML file, remove all HTML tags
    (including comments, etc.), replace all ENTITIES (e.g. &amp), and put the
    result into a variable as a string. I figure HTML::parser itself can
    somehow preform the filtering, but how do I get it back as a string? I'd
    appreciate some sample code if anyone has any. Sorry if this is a real n00b
    question.

    Thanks a lot,
    Mitchua
     
    Mitchua, Jul 14, 2003
    #1
    1. Advertising

  2. Mitchua

    Ice Demon Guest

    "Mitchua" <> wrote in message
    news:pvmQa.23629$...
    > I am trying to use HTML::parser to parse an HTML file, remove all HTML

    tags
    > (including comments, etc.), replace all ENTITIES (e.g. &amp), and put the
    > result into a variable as a string. I figure HTML::parser itself can
    > somehow preform the filtering, but how do I get it back as a string? I'd
    > appreciate some sample code if anyone has any. Sorry if this is a real

    n00b
    > question.
    >
    > Thanks a lot,
    > Mitchua


    Try this for a sample of parsing a webpage
    http://www.wdvl.com/Authoring/Languages/Perl/PerlfortheWeb/summarizer.html
    If you are just trying to remove all the html tags, you could just do this
    $webpage =~ s/<.*?>//g;

    Ice Demon
    http://adult-xxx-newsgroups.com
    http://adult-cybergames.com
    http://adult-spider.com
     
    Ice Demon, Jul 15, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike
    Replies:
    3
    Views:
    882
    Michael Borgwardt
    Jan 9, 2004
  2. keto
    Replies:
    0
    Views:
    980
  3. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    366
    David Cournapeau
    Dec 30, 2008
  4. Michael Tan
    Replies:
    32
    Views:
    1,006
    Ara.T.Howard
    Jul 21, 2005
  5. Mister Yu
    Replies:
    0
    Views:
    134
    Mister Yu
    Sep 30, 2007
Loading...

Share This Page