Instantly share code, notes, and snippets.

Embed
What would you like to do?
translate between tatar and russian from CLI
#!/usr/bin/env python3
import sys
from urllib.parse import quote
from lxml import html
if len(sys.argv) > 1:
word = sys.argv[1]
url = "http://tatpoisk.net/dict/" + quote(word)
results = html.parse(url).getroot().cssselect(".search_results")
if results:
translation = results[0].text_content()
print(translation)
else:
print("could not translate", word)
else:
print("please specify your word")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment