Created
April 22, 2017 14:06
-
-
Save meoyawn/ee82356791cfc8c935aaa455826450f6 to your computer and use it in GitHub Desktop.
translate between tatar and russian from CLI
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
#!/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