-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeprem.py
35 lines (29 loc) · 1.01 KB
/
Deprem.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import requests
import json
import time
import os
from playsound import playsound
while True:
#Hazır api kullanılarak veri çekildi.
url = "https://api.orhanaydogdu.com.tr/deprem/kandilli/live"
response = requests.get(url)
answer = json.loads(response.text)
#print(json)
#Veri düzenlendi.
sayac = 0
ses_sayaci = 0
print("{:<30} {:<40} {:<15} {:<15}".format('Tarih', 'Bölge', 'Büyüklük', 'Derinlik')) # {:<} sayesinde yazı pozisyonları değiştirildi.
for i in answer["result"]:
if sayac > 10:
break
elif (i["mag"]>3):
print("{:<30} {:<40} {:<15} {:<15}".format(i["date"], i["title"], i["mag"], i["depth"]))
sayac += 1
elif ('İSTANBUL' in i["title"]):
if ses_sayaci == 1:
continue
playsound('https://cdn.glitch.global/7694129e-5292-4bc4-8425-b6bf7800765d/Ses.mp3')
ses_sayaci += 1
time.sleep(30)
os.system('cls')
sayac = 0