Need help with umlaut in URL
i try to update my kino.de script at the moment. Now i ran into some problem:
if i want to get cinemadata from citys with no umlaut or special character everythings works well, but if i try to fetch pages from citys with umlaut, i get the wrong page, because the umlauts or special characters are wrong encoded (i think)
so here is the code snipped:
def getPage(self, city, pages):
# city comes from a list of unicode strings!
url = 'http://kino.de/kinosuche.php4?searchortplz='
url = url + urllib.quote(city,'/=&:?')
self.filmContentText.setText(url)
debugwrite(str(url))
pagetext = urllib.urlopen(str(url)).read()
pagetext = pagetext.decode('iso-8859-1')
self.filmContentText.setText(pagetext)
self.HTMLPage = pagetext
if i enter the url in my browser i get the right side:
for example:
M黱chen:
http://kino.de/kinosuche.php4?searchortplz=M%FCnchen
but with the urlopen i get the side from
http://kino.de/kinosuche.php4?searchortplz=M%25FCnchen
so in the form on the page is "M%FCnchen" written instead of the wanted "M黱chen"
please help!
Tia
Morte
Nuka was right with the quoting, but i had to encode the string as latin-1 at the end. so here is the working code (maybe someone runs into the same problem as i did)
def getPage(self, city, pages):
url = 'http://kino.de/kinosuche.php4?searchortplz='
url = url + city
url = url.encode('latin-1')
pagetext = urllib.urlopen(str(url)).read()
pagetext = pagetext.decode('iso-8859-1')
self.filmContentText.setText(pagetext)
self.HTMLPage = pagetext
THX NUKA
url = url + city
#If you have any other info about this subject , Please add it free.# |