Kodi Community Forum
Need help with umlaut in URL - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: Need help with umlaut in URL (/showthread.php?tid=24349)



Need help with umlaut in URL - morte0815 - 2007-01-19

Hi,

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:

PHP Code:
def getPage(selfcitypages):
        
# 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ünchen:
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ünchen"


please help!

Tia

Morte


- Nuka1195 - 2007-01-19

Don't quote the city.

Quote:url = url + city




- morte0815 - 2007-01-19

Now i got it working.

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)

PHP Code:
def getPage(selfcitypages):
        
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