is giving invalid url error for Google Translation API for Translating language from Tamil to English

Am getting Invalid URL at index 145 error in the below code. Basically, this code is accessing the Google Translate API to do the translation
Here is my code:
url = "அனைத்தும்+திறந்திருக்கும்&oe=UTF-16&tk=xxxx&tl=en-US&client=gtx&sl=auto&ie=UTF-16"

response =
response = client.get(url)
result = response.getText()
print response

You have international characters in a python conventional string constant. You need to mark the string constant as unicode, like so:

u"some string with unicode"

Also, you are creating an httpClient instance in every request. This will leak memory and produce many stale threads. Create one instance as a top-level variable in a project library script and use it for all of your requests.

1 Like