View Single Post
Old 03-19-2011, 04:51 PM   #2
bubak
Connoisseur
bubak began at the beginning.
 
Posts: 65
Karma: 10
Join Date: Dec 2010
Device: kindle voyage
For anyone who may be interested: The encoding function expects just one argument, source, the first one is the usual 'self' of Python. The url-dependent encoding can be done as follows:

Code:
    def encoding(self, source):
        if source.newurl.find('blog.aktualne') >= 0:
            enc = 'utf-8'
        else:
            enc = 'iso-8859-2'
        self.log.debug('Called encoding ' + enc + " " + str(source.newurl))
        return source.decode(enc, 'replace')
bubak is offline   Reply With Quote