A python script that expects a query, a source and a target language, then sends an appropriate query to Linguee.com, parses the HTML response, and prints a condensed version of said response. I use this in tandem with xsel to quickly translate selected text and show the translation as a desktop notification.
python main.py "get excited" EN DE
Empty, non-alphabetic or overlong queries (with more than 3 words and/or 50 characters) as well as unknown language codes will result in an error and not send a request to Linguee (cf. _validate_arguments). To further reduce traffic the script keeps a history of past queries and their translations via a hidden .lingue_cli.csv file in the home directory.
- requests
- BeautifulSoup
If you use this script, make sure you comply with the Linguee Terms and Conditions and especially this clause:
Both private and business usage of linguee.com services is free of charge. It is however strictly prohibited to forward on our services to third parties against payment.