[Release] Parsedom and other functions
#94
For me it wasn't really errors in fetchpage itself, it was my crappy code - this was the first python I ever wrote and I was calling member function of str (e.g. strip.strip()) - directly, rather than on the string object. All the str functions exist for unicode as well, so I just called them directly on the string object, i.e. mystir.strip() instead.

Honestly, I looked in there and was embarrassed at what I saw!! I was quite a while ago now, but geez some ugly code is in there. Still, it works - indeed if I'd jsut written it properly to start, it would have worked even with the parsedom changes, so my bad really.

In your case, maybe pinch the fetchpage function from the older parsedom as an ugly workaround to keep going??

(At a guess on your issue: I would say you're getting strings back with embedded unicode in them - there's a well known bug for this in Python that requires a hack to get around - I came across this in XSqueeze and solve it with a function):

Code:
def unquoteUni(text):

    try:
        import urllib.parse
        return urllib.parse.unquote(text, encoding=self.charset)
    except ImportError:
        _hexdig = '0123456789ABCDEFabcdef'
        _hextochr = dict((a+b, chr(int(a+b,16))) for a in _hexdig for b in _hexdig)
        if isinstance(text, unicode):
            text = text.encode('utf-8')
        res = text.split('%')
        for i in xrange(1, len(res)):
            item = res[i]
            try:
                res[i] = _hextochr[item[:2]] + item[2:]
            except KeyError:
                res[i] = '%' + item
            except UnicodeDecodeError:
                res[i] = unichr(int(item[:2], 16)) + item[2:]
        return "".join(res)

giftie helped me find (or wrote? dude is awesome) - that function which deals with unicode in strings....this is for the case where you have a str type but with actually unicode in it like 'The message is \xe8\x91\xa3' or similar...those characters are unicode encoded (even though the type is str) - and fall outside of the ascii range hence the error you get above. The normal unquote does not work...

Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply


Messages In This Thread
[No subject] - by Popeye - 2011-12-09, 12:01
[No subject] - by TobiasTheCommie - 2011-12-09, 17:42
[No subject] - by Popeye - 2011-12-09, 23:16
[No subject] - by TobiasTheCommie - 2011-12-10, 06:43
[No subject] - by _Pierre_ - 2011-12-10, 12:43
[No subject] - by bossanova808 - 2011-12-11, 06:42
[No subject] - by TobiasTheCommie - 2011-12-11, 13:09
[No subject] - by bossanova808 - 2011-12-11, 14:16
[No subject] - by TobiasTheCommie - 2011-12-11, 14:27
[No subject] - by bossanova808 - 2011-12-11, 14:35
[No subject] - by TobiasTheCommie - 2011-12-12, 01:58
[No subject] - by bossanova808 - 2011-12-12, 08:20
[No subject] - by _Pierre_ - 2011-12-12, 11:40
[No subject] - by TobiasTheCommie - 2011-12-12, 12:13
[No subject] - by TobiasTheCommie - 2011-12-12, 14:03
[No subject] - by _Pierre_ - 2011-12-12, 14:13
[No subject] - by TobiasTheCommie - 2011-12-12, 14:34
[No subject] - by _Pierre_ - 2011-12-12, 15:47
[No subject] - by TobiasTheCommie - 2011-12-12, 16:12
[No subject] - by _Pierre_ - 2011-12-12, 18:13
[No subject] - by TobiasTheCommie - 2011-12-12, 18:55
[No subject] - by _Pierre_ - 2011-12-12, 19:11
[No subject] - by TobiasTheCommie - 2011-12-12, 19:24
[No subject] - by bossanova808 - 2011-12-13, 01:20
[No subject] - by TobiasTheCommie - 2011-12-13, 02:00
[No subject] - by bossanova808 - 2011-12-13, 02:06
[No subject] - by TobiasTheCommie - 2011-12-13, 02:28
[No subject] - by bossanova808 - 2011-12-13, 04:10
[No subject] - by newatv2user - 2011-12-13, 06:53
[No subject] - by TobiasTheCommie - 2011-12-13, 15:55
[No subject] - by newatv2user - 2011-12-13, 17:24
[No subject] - by _Pierre_ - 2011-12-13, 20:18
[No subject] - by TobiasTheCommie - 2011-12-13, 23:08
[No subject] - by _Pierre_ - 2011-12-14, 21:25
[No subject] - by TobiasTheCommie - 2011-12-14, 22:13
[No subject] - by _Pierre_ - 2011-12-14, 22:27
[No subject] - by _Pierre_ - 2011-12-15, 20:11
[No subject] - by Martijn - 2011-12-15, 20:17
[No subject] - by _Pierre_ - 2011-12-15, 20:27
[No subject] - by Martijn - 2011-12-15, 20:32
[No subject] - by _Pierre_ - 2011-12-15, 20:35
[No subject] - by TobiasTheCommie - 2011-12-16, 00:33
[No subject] - by TobiasTheCommie - 2011-12-16, 00:37
[No subject] - by bossanova808 - 2011-12-16, 00:54
[No subject] - by bossanova808 - 2011-12-16, 00:55
[No subject] - by TobiasTheCommie - 2011-12-16, 01:40
[No subject] - by newatv2user - 2011-12-16, 02:17
[No subject] - by TobiasTheCommie - 2011-12-16, 02:29
[No subject] - by takoi - 2011-12-20, 23:54
[No subject] - by TobiasTheCommie - 2011-12-21, 00:25
[No subject] - by takoi - 2011-12-21, 13:35
[No subject] - by stacked - 2011-12-22, 04:05
[No subject] - by TobiasTheCommie - 2011-12-22, 04:07
[No subject] - by takoi - 2011-12-25, 22:34
[No subject] - by TobiasTheCommie - 2011-12-25, 23:48
[No subject] - by takoi - 2011-12-26, 01:54
[No subject] - by TobiasTheCommie - 2011-12-26, 03:57
[No subject] - by takoi - 2012-01-03, 15:06
[No subject] - by TobiasTheCommie - 2012-01-03, 15:46
[No subject] - by takoi - 2012-01-05, 17:47
[No subject] - by TobiasTheCommie - 2012-01-05, 17:59
[No subject] - by takoi - 2012-01-08, 15:19
[No subject] - by TobiasTheCommie - 2012-01-08, 15:30
[No subject] - by BlueCop - 2012-01-09, 23:02
[No subject] - by TobiasTheCommie - 2012-01-27, 01:42
[No subject] - by bossanova808 - 2012-01-27, 07:51
[No subject] - by TobiasTheCommie - 2012-01-27, 13:16
[No subject] - by newatv2user - 2012-01-30, 04:34
[No subject] - by TobiasTheCommie - 2012-01-30, 15:49
[No subject] - by newatv2user - 2012-01-31, 02:18
[No subject] - by TobiasTheCommie - 2012-01-31, 02:24
[No subject] - by newatv2user - 2012-01-31, 02:36
[No subject] - by newatv2user - 2012-01-31, 05:22
[No subject] - by newatv2user - 2012-02-04, 06:14
[No subject] - by TobiasTheCommie - 2012-02-04, 12:08
[No subject] - by newatv2user - 2012-02-04, 16:42
[No subject] - by TobiasTheCommie - 2012-02-04, 17:37
[No subject] - by newatv2user - 2012-02-05, 08:34
[No subject] - by TobiasTheCommie - 2012-02-05, 12:11
[No subject] - by newatv2user - 2012-02-05, 16:51
RE: [Release] Parsedom and other functions - by bossanova808 - 2012-09-21, 01:50
Logout Mark Read Team Forum Stats Members Help
[Release] Parsedom and other functions1