Created
January 27, 2020 07:48
-
-
Save meysampg/1978a8b72bcfd9ae0aec5cef1b952c8d to your computer and use it in GitHub Desktop.
A snippet for fetching data from Google translate API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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