Last active
March 10, 2016 09:18
-
-
Save gtors/9d0ca49a5ed1c2a59e28 to your computer and use it in GitHub Desktop.
Simple console en-ru translator.
This file contains 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
#!/usr/bin/env python | |
#---------------------------------------------------------------------- | |
# Imports | |
#---------------------------------------------------------------------- | |
import sys | |
import json | |
import requests | |
#---------------------------------------------------------------------- | |
# Code | |
#---------------------------------------------------------------------- | |
URI = 'https://translate.yandex.net/api/v1.5/tr.json/translate' | |
KEY = '' | |
if __name__ == '__main__': | |
resp = requests.get(URI, params={ | |
"key": KEY, | |
"lang": "en-ru", | |
"text": " ".join(sys.argv[1:]), | |
"format": "plain" | |
}) | |
print(json.loads(resp.content.decode('utf-8'))["text"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment