Skip to content

Instantly share code, notes, and snippets.

@meysampg
Created January 27, 2020 07:48
Show Gist options
  • Save meysampg/1978a8b72bcfd9ae0aec5cef1b952c8d to your computer and use it in GitHub Desktop.
Save meysampg/1978a8b72bcfd9ae0aec5cef1b952c8d to your computer and use it in GitHub Desktop.
A snippet for fetching data from Google translate API
import requests
def trans(w, source="en", target="fa"):
url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl={0}&tl={1}&dt=t&q={2}".format(source, target, w)
resp = requests.get(url)
return resp.json()[0][0][0]
print(trans("khubi?"))
# خوبی؟
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment