Last active
July 13, 2020 23:59
-
-
Save aliorhun/edd72f1ce3a33c2be87bd1c5cf6cf211 to your computer and use it in GitHub Desktop.
Corona günlük sayı öğrenme
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 python | |
| import pytesseract | |
| from PIL import Image, ImageOps | |
| from io import BytesIO | |
| import requests | |
| import json | |
| import os | |
| from datetime import datetime | |
| import locale | |
| online=1 | |
| now = datetime.now() | |
| locale.setlocale(locale.LC_ALL, "tr_TR.utf-8") | |
| filename=now.strftime('%d')+now.strftime('%B').lower()+now.strftime('%Y')+"-1.jpg" | |
| def main(args): | |
| if online==1: | |
| try: | |
| response = requests.get("https://covid19.saglik.gov.tr/img/"+filename) | |
| image1 = Image.open(BytesIO(response.content)) | |
| except requests.exceptions.RequestException as e: | |
| raise SystemExit(e) | |
| else: | |
| try: | |
| os.path.exists(filename) | |
| image1 = Image.open(filename) | |
| except FileNotFoundError: | |
| print("dosya yok veya dosya adını yanlış girdin") | |
| exit() | |
| print(gunluk(image1)) | |
| return 0 | |
| def gunluk(img): | |
| gri = img.convert('L') | |
| siyahbeyaz = ImageOps.invert(gri) | |
| text = pytesseract.image_to_string(siyahbeyaz,lang="tur", config="--psm 1 --dpi 1200 --oem 0") | |
| text1=text.split("\n") | |
| text1 = [e for e in text1 if e] | |
| ozetdict = {'test': text1[-3],'hasta': text1[-2],'vefat': text1[-1]} | |
| ozet_json = json.dumps(ozetdict) | |
| return ozet_json | |
| if __name__ == '__main__': | |
| import sys | |
| sys.exit(main(sys.argv)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment