2 Mar 2003 01:17
UnicodeError: ASCII encoding error: ordinal not in range(128)
Hasan Diwan <hdiwan <at> localhost>
2003-03-02 00:17:45 GMT
2003-03-02 00:17:45 GMT
I have a script to parse RSS feeds into HTML. Some of these RSS feeds contain characters outside the 7-bit ASCII range, and the page is set to display in utf8. My question is how to force the script below to output strings in UTF8 as opposed to ASCII: #!/sw/bin/python from xml.dom import minidom import string import urllib import time import sys import re import zlib #Change these to reflect your reality class news: def load(self, url): p=None try: p=minidom.parse(urllib.urlopen(url)) except: print 'unreachable URL '+url, return p DEFAULT_NAMESPACES = \ (None, # RSS 0.91, 0.92, 0.93, 0.94, 2.0 'http://purl.org/rss/1.0/', # RSS 1.0 'http://my.netscape.com/rdf/simple/0.9/' # RSS 0.90 ) def getElementsByTagName(self, node, tagName, possibleNamespaces=DEFAULT_NAMESPACES): for namespace in possibleNamespaces: children = node.getElementsByTagName(tagName)(Continue reading)
RSS Feed