I am trying to parse a last.fm xml file to get the artists, tracks, etc. into a django database. I am having an issue where foreign characters (Japanese, etc.) are being stored in the database as "?????" and not the correct values. I feel like I've tried everything, and am getting pretty frustrated, so I thought I would see if anyone had any ideas of what I might be doing wrong. here is my current code:
import urllib import elementtree.ElementTree as ET try: tree = ET.parse(urllib.urlopen("http://ws.audioscrobbler.com/1.0/ user/drackett/weeklytrackchart.xml")) x = tree.getroot() if not Update.objects.filter(ident=x.attrib.get('from')): global_id = x.attrib.get('from') for track in x: try: test = Artist.objects.get(mbid=track.find('artist').attrib.get('mbid')) except Artist.DoesNotExist: a = Artist( name = track.find('artist').text, mbid = track.find('artist').attrib.get('mbid'), ) a.save() try: test = Track.objects.get(url=track.find('url').text) except Track.DoesNotExist: t = Track( name = track.find('name').text, artist = Artist.objects.get(mbid=track.find('artist').attrib.get('mbid')), url = track.find('url').text, ) t.save() u = Update( track = Track.objects.get(url=track.find('url').text), position = track.find('chartposition').text, playcount = track.find('playcount').text, ident = global_id, ) u.save() except: print "issue with import" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---