Hi. I want to use Google Language Detection API in my app to detect language of url parameter. For example user requests url
http://myapp.com/q?Это тест
and gets message "Russian". I do it this way:
def get(self):
url = "http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&q="+self.request.query
try:
data = json.loads(urllib2.urlopen(url).read())
self.response.out.write('<html><body>' + data["responseData"]["language"] +'</body></html>')
except urllib2.HTTPError, e:
self.response.out.write( "HTTP error: %d" % e.code )
except urllib2.URLError, e:
self.response.out.write( "Network error: %s" % e.reason.args[1])
but always get "English" as result because url is encoded in
I've tried urllib.quote , urllib.urlencode
with no luck.
How I have to decode this url for Google Api?