Seite 1 von 1

feedparser UnicodeDecodeError

Verfasst: Freitag 6. Juli 2007, 09:10
von .robert
Hallo,
ich habe ein kleines Problem mit dem Feedparser:

Code: Alles auswählen

>>>import feedparser
>>>f = feedparser.parse('http://feeds.feedburner.com/Bildblog')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/var/lib/python-support/python2.5/feedparser.py", line 2623, in parse
    feedparser.feed(data)
  File "/var/lib/python-support/python2.5/feedparser.py", line 1441, in feed
    sgmllib.SGMLParser.feed(self, data)
  File "sgmllib.py", line 99, in feed
    self.goahead(0)
  File "sgmllib.py", line 138, in goahead
    k = self.parse_endtag(i)
  File "sgmllib.py", line 315, in parse_endtag
    self.finish_endtag(tag)
  File "sgmllib.py", line 355, in finish_endtag
    self.unknown_endtag(tag)
  File "/var/lib/python-support/python2.5/feedparser.py", line 476, in unknown_endtag
    method()
  File "/var/lib/python-support/python2.5/feedparser.py", line 1318, in _end_content
    value = self.popContent('content')
  File "/var/lib/python-support/python2.5/feedparser.py", line 700, in popContent
    value = self.pop(tag)
  File "/var/lib/python-support/python2.5/feedparser.py", line 641, in pop
    output = _resolveRelativeURIs(output, self.baseuri, self.encoding)
  File "/var/lib/python-support/python2.5/feedparser.py", line 1594, in _resolveRelativeURIs
    p.feed(htmlSource)
  File "/var/lib/python-support/python2.5/feedparser.py", line 1441, in feed
    sgmllib.SGMLParser.feed(self, data)
  File "sgmllib.py", line 99, in feed
    self.goahead(0)
  File "sgmllib.py", line 133, in goahead
    k = self.parse_starttag(i)
  File "sgmllib.py", line 291, in parse_starttag
    self.finish_starttag(tag, attrs)
  File "sgmllib.py", line 333, in finish_starttag
    self.unknown_starttag(tag, attrs)
  File "/var/lib/python-support/python2.5/feedparser.py", line 1589, in unknown_starttag
    _BaseHTMLProcessor.unknown_starttag(self, tag, attrs)
  File "/var/lib/python-support/python2.5/feedparser.py", line 1458, in unknown_starttag
    value = unicode(value, self.encoding)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 3-6: invalid data
>>>
Wie kann ich das am besten behandeln?
Ich kann den Feed mit anderen "readern", z.b Firefox ohne Probleme anzeigen lassen.
Kann man da irgend was anderes machen ausser das per "try ..." zu unterbinden?
Und überhaupt, wo liegt der Fehler?

Danke für jede Unterstützung...

Verfasst: Mittwoch 11. Juli 2007, 14:21
von brenmcguire
Schau mal hier nach: http://feedparser.org/docs/character-encoding.html

Scheinbar hat der Parser Probleme mit dem Encoding der emfangenen Daten.

Verfasst: Mittwoch 11. Juli 2007, 15:19
von mitsuhiko
Riecht nach Bug. Schreib einfach Mark Pilgrim an :-)