Problems with joining Unicode strings

Ulysse maxime.p at
Sun Mar 23 21:58:22 CET 2008


I have problems with joining strings.

My program get web page fragments, then joins them into one single web
page. I have error when I try to join these fregments :
"UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position
208: ordinal not in range(128)"

Here is my code :

# Parcours des RSS
f = open('soupresult.html', 'w')
d = feedparser.parse(rss_url)
separator = '<hr>'
data = ''
refresh_time = 2*60*60 #Secondes
resume_news = []

# Parcours des RSS
if len(d['items']) > 0:
    now =
    for item in d['items']:
        item_date = item.date_parsed
        print item_date
        item_date2 = datetime.datetime(item_date[0], item_date[1],
item_date[2], item_date[3], item_date[4], item_date[5])
        age_item = now - item_date2
        age_item = age_item.days*24*3600 + age_item.seconds

        if age_item < refresh_time:
            url = item['link']
            print item.title
                req = urllib2.Request(url)
                browser = urllib2.urlopen(req)
                data =
                clean_item = data

            except urllib2.URLError, e:
                print e.code

More information about the Python-list mailing list