Last active
January 9, 2023 15:54
-
-
Save KebabLord/5a136d898cb31c6875de35ed6de86be6 to your computer and use it in GitHub Desktop.
turengo, npm tureng ve tarayıcı eklentileri olsun yazılmış hiçbir tureng scripti an itibariyle çalışmadığından şu 16 satırlık zımbırtıyı yazmak zorunda kaldım.
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 python3 | |
# Kullanım: ./tureng.py kelime [-f -s] | |
import requests,re,html,sys | |
useragent="Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0" | |
res = requests.get(f"https://tureng.com/en/turkish-english/{sys.argv[1]}",headers={"User-Agent":useragent}).text | |
words = re.findall(r'"hidden\-xs">(.*?)<.*?lang="(.*?)">.*?>(.*?)<.*?lang="(.*?)">.*?>(.*?)<',res,flags=re.S|re.M) | |
prettify = lambda x: html.unescape(x).replace("\n","").replace("\r","").replace("Turkish","TR").replace("English","EN") | |
for word in words: | |
usage = prettify(word[0]) | |
w1 = prettify(word[2]) | |
w2 = prettify(word[4]) | |
if not "-f" in sys.argv and len(w1)+len(w2)>90: | |
continue | |
print(f"{usage : <11}\t[{w1}]\t[{w2}]") | |
if "-s" in sys.argv: | |
break |
Author
KebabLord
commented
Jan 4, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment