Perl HTML Parser does not work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • szepesg
    New Member
    • Jul 2008
    • 10

    #1

    Perl HTML Parser does not work

    Hi!

    If I want to parse this html file (e.g. copy it into an other file using HTML Parser) I only get an empty file.
    What am I doing wrong?
    Thank you for your answer in advance.

    Gábor
  • szepesg
    New Member
    • Jul 2008
    • 10

    #2
    I forgot to mention that if I am working with a much simpler file e.g. an HTML file that has only 5 or 6 rows then everything is fine.

    Gábor

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3
      See where my finger is pointing? That is where you are making a mistake.

      Comment

      • eWish
        Recognized Expert Contributor
        • Jul 2007
        • 973

        #4
        Showing use the code would result in KevinADC not having to use his fingers.

        --Kevin

        Comment

        • szepesg
          New Member
          • Jul 2008
          • 10

          #5
          Hello,

          This is the code I used:

          Code:
          #!/usr/bin/perl -w
             
           use strict;
           
          
           # define the subclass
           package IdentityParse;
           use base "HTML::Parser";
          
           open(OUT,">placid.html");
            
           sub text {
               my ($self, $text) = @_;
               # just print out the original text
               print OUT $text;
           }
           
           #sub comment {
            #   my ($self, $comment) = @_;
             #  # print out original text with comment marker
              # print OUT "";
          # }
             
           sub start {
               my ($self, $tag, $attr, $attrseq, $origtext) = @_;
               # print out original text
               print OUT $origtext;
           }
           
           sub end {
               my ($self, $tag, $origtext) = @_;
               # print out original text
               print OUT $origtext;
           }
           my $p = new IdentityParse;
           $p->parse_file("index.html");
          Thank you for your help in advance:

          Gábor
          Last edited by eWish; Aug 24 '08, 02:45 PM. Reason: Please use [code][/code] tags

          Comment

          • szepesg
            New Member
            • Jul 2008
            • 10

            #6
            Hello Guys,

            It was all my mistake. The file's name I wanted to parse was x.htm and not x.html.
            Sorry for bothering the forum.
            I am new to perl I thought that there is a much complex problem.
            Sorry again.

            Gábor

            Comment

            Working...