feedparser UnicodeDecodeError

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
.robert
User
Beiträge: 274
Registriert: Mittwoch 25. April 2007, 17:59

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...
Benutzeravatar
brenmcguire
User
Beiträge: 9
Registriert: Donnerstag 28. Juni 2007, 08:33

Schau mal hier nach: http://feedparser.org/docs/character-encoding.html

Scheinbar hat der Parser Probleme mit dem Encoding der emfangenen Daten.
mitsuhiko
User
Beiträge: 1790
Registriert: Donnerstag 28. Oktober 2004, 16:33
Wohnort: Graz, Steiermark - Österreich
Kontaktdaten:

Riecht nach Bug. Schreib einfach Mark Pilgrim an :-)
TUFKAB – the user formerly known as blackbird
Antworten