Skip to content

Instantly share code, notes, and snippets.

@KebabLord
Last active January 9, 2023 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KebabLord/5a136d898cb31c6875de35ed6de86be6 to your computer and use it in GitHub Desktop.
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.
#!/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
@KebabLord
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment