Skip to content

Instantly share code, notes, and snippets.

@gtors
Last active March 10, 2016 09:18
Show Gist options
  • Save gtors/9d0ca49a5ed1c2a59e28 to your computer and use it in GitHub Desktop.
Save gtors/9d0ca49a5ed1c2a59e28 to your computer and use it in GitHub Desktop.
Simple console en-ru translator.
#!/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