
Originally Posted by
impazzito
no.. sorry but i'm very novice in python.. i have to add your code with my code?
Yes ! Just copy the code snippet. Something like (not tested, but should work):
Code:
import appuifw
import globalui
import re
import urllib
def safe_unicode(value):
"http://aspyplayer.googlecode.com/svn/trunk/src/aspyplayer.py"
if type(value) == type(unicode("unicode")):
return value
result = ""
for enc in ['utf8', 'latin1']:
try:
result = value.decode(enc)
break
except:
pass
return unicode(result)
def decode_html(line):
"http://mail.python.org/pipermail/python-list/2006-April/378536.html"
pat = re.compile(r'&#(\d+);')
def sub(mo):
return unichr(int(mo.group(1)))
return pat.sub(sub, safe_unicode(line))
def ricevi():
url = 'http://oroscopo.libero.it/oro_tab/l.phtml'
response = urllib.urlopen(url).read()
try:
oroscopo = (re.search('<div class="oroscopo_oggi">\x0a(.*?)\x0a</div>', response).group(1))
except:
oroscopo = u"Impossible to decode"
msg = decode_html(oroscopo) # <<<<<=========== HERE
globalui.global_msg_query(msg, u"Pesci:")
appuifw.app.orientation='automatic'
ricevi()
appuifw.app.set_exit()