issues with htmlparser.getpos

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dysmas

    #1

    issues with htmlparser.getpos

    Hi,


    Im having an issue with HTMLParser, the getpos() funtion sometimes
    returns things like :

    (1, 1247)
    (1, 2114)
    (1, 2168)
    (1, 2228)
    (1, 2295)
    (1, 2382)
    (1, 2441)
    (1, 2963)
    (1, 3040)

    i guess this is because the HTMLParser has not correctly parsed the
    newline characters in the string fed to it... is there a workaround
    for this, without checking the string every time i feed it some data?

  • Steve Holden

    #2
    Re: issues with htmlparser.getp os

    dysmas wrote:
    Hi,
    >
    >
    Im having an issue with HTMLParser, the getpos() funtion sometimes
    returns things like :
    >
    (1, 1247)
    (1, 2114)
    (1, 2168)
    (1, 2228)
    (1, 2295)
    (1, 2382)
    (1, 2441)
    (1, 2963)
    (1, 3040)
    >
    i guess this is because the HTMLParser has not correctly parsed the
    newline characters in the string fed to it... is there a workaround
    for this, without checking the string every time i feed it some data?
    >
    Have you verified that these results aren't correct? There is no
    requirements for newlines in HTML, and some computer-generated pages
    don't bother to insert them.

    regards
    Steve
    --
    Steve Holden +1 571 484 6266 +1 800 494 3119
    Holden Web LLC/Ltd http://www.holdenweb.com
    Skype: holdenweb http://del.icio.us/steve.holden
    --------------- Asciimercial ------------------
    Get on the web: Blog, lens and tag the Internet
    Many services currently offer free registration
    ----------- Thank You for Reading -------------

    Comment

    • rokadvertising@googlemail.com

      #3
      Re: issues with htmlparser.getp os

      Steve,

      thanks for reply

      there are newlines present, it looks like the files in question are
      from a mac, (my text editor tells me they are UTF8 & use CR for
      marking newlines)

      Cheers

      Comment

      • rokadvertising@googlemail.com

        #4
        Re: issues with htmlparser.getp os

        On Jul 4, 1:47 pm, rokadvertis...@ googlemail.com wrote:
        Steve,
        >
        thanks for reply
        >
        there are newlines present, it looks like the files in question are
        from a mac, (my text editor tells me they are UTF8 & use CR for
        marking newlines)
        >
        Cheers
        d0h,

        f = open(this_file, "U")
        ^^^^
        \ this fixed it

        cheers anyway ;)

        Comment

        Working...