-
Notifications
You must be signed in to change notification settings - Fork 0
/
anlikdeprem.py
40 lines (33 loc) · 1.3 KB
/
anlikdeprem.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
36
37
38
39
40
# -*- coding:utf-8 -*-
import time as time_lib
import requests
from bs4 import BeautifulSoup
import pywhatkit
import os
import webbrowser
def get_latest_earthquake_data():
url = "https://deprem.afad.gov.tr/last-earthquakes.html"
html_content = requests.get(url).text
soup = BeautifulSoup(html_content, "html.parser")
table = soup.find("table")
if table:
earthquake_rows = table.find_all("tr")[1:]
latest_earthquake_row = earthquake_rows[0]
columns = latest_earthquake_row.find_all("td")
date = columns[0].text
magnitude = columns[5].text
depth = columns[3].text
location = columns[6].text
earthquake_info = f" >>>>>>>>>>>>>>>Yeni deprem olcumu yapildi! Tarih: {date}, Siddet: {magnitude}, Derinlik: {depth}, Yer: {location} "
return earthquake_info
previous_data = None
while True:
earthquake_data = get_latest_earthquake_data()
if earthquake_data != previous_data:
print(earthquake_data)
previous_data = earthquake_data
webbrowser.open('https://google.com/', new=2)
pywhatkit.sendwhatmsg_to_group_instantly("group_id", get_latest_earthquake_data())
time_lib.sleep(5)
os.system("taskkill /f /im chrome.exe")
time_lib.sleep(60)