-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbanu.py
150 lines (136 loc) · 7.83 KB
/
banu.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import requests
for x in range(100):
print("")
print("")
print("---< Meminta data pada BMKG >---")
print("")
htmltext = "Error, Tidak Bisa Memukan Url yang di cari"
try:
url = requests.get("https://data.bmkg.go.id/datamkg/MEWS/DigitalForecast/DigitalForecast-DIYogyakarta.xml")
htmltext = url.text
url = requests.get("https://data.bmkg.go.id/autogempa.xml")
htmltext2 = url.text
except:
print("/!\ Error Can't find BMKG Data Cuaca")
print("---< Ada Masalah Ketika Meminta Data Cuaca BMKG di DI Yogyakarta >---")
print("/!\ Coba:")
print("/!\ -Pastikan Internet Terhubung")
else:
print("")
print("---< Data di terima >---")
print("")
print("")
print("---< Membuka Data dari BMKG di DI Yogyakarta >---")
print("")
print("")
print("---| Info Waktu |---")
print("")
print(htmltext[htmltext.find("<timestamp>"):htmltext.find("</timestamp>")].replace("<timestamp>", "Waktu terdeteksi "))
print(htmltext[htmltext.find("<year>"):htmltext.find("</year>")].replace("<year>", "tahun "))
print(htmltext[htmltext.find("<day>"):htmltext.find("</day>")].replace("<day>", "hari "))
print(htmltext[htmltext.find("<minute>"):htmltext.find("</minute>")].replace("<minute>", "menit "))
print(htmltext[htmltext.find("<second>"):htmltext.find("</second>")].replace("<second>", "detik "))
print("")
print("---| BMKG ->X<- Banu - [Menu Kabupaten] |---")
print("")
kabdat = htmltext
listkabupaten = []
for x in range(len(htmltext)):
if len(kabdat) == 0:
break
kabdat = kabdat[kabdat.find('<name xml:lang="id_ID">'):len(kabdat)]
listkabupaten.append(kabdat[kabdat.find('<name xml:lang="id_ID">'):kabdat.find("</name>")].replace('<name xml:lang="id_ID">', ""))
kabdat = kabdat[kabdat.find("</name>")+7:len(kabdat)]
del listkabupaten[len(listkabupaten)-1]
c = 0
for x in listkabupaten:
print(x + " < " + str(c))
c += 1
print("")
print("---| BMKG ->X<- Banu - [Menu Kabupaten] |---")
print("")
print("Silahkan dipilih nama Kabupatennya dan ketik nomornya saja")
print("Antara 0 sampai " + str(len(listkabupaten)-1))
print("")
try:
Kabupaten = listkabupaten[int(input('>nomor>'))]
for x in range(100):
print("")
print("")
print("---| Info Waktu |---")
print("")
print(htmltext[htmltext.find("<timestamp>"):htmltext.find("</timestamp>")].replace("<timestamp>", "Waktu terdeteksi "))
print(htmltext[htmltext.find("<year>"):htmltext.find("</year>")].replace("<year>", "tahun "))
print(htmltext[htmltext.find("<day>"):htmltext.find("</day>")].replace("<day>", "hari "))
print(htmltext[htmltext.find("<minute>"):htmltext.find("</minute>")].replace("<minute>", "menit "))
print(htmltext[htmltext.find("<second>"):htmltext.find("</second>")].replace("<second>", "detik "))
htmltext = htmltext[htmltext.find('<name xml:lang="id_ID">' + Kabupaten):htmltext[htmltext.find('<name xml:lang="id_ID">' + Kabupaten):len(htmltext)].find("</area>")+htmltext.find('<name xml:lang="id_ID">' + Kabupaten)]
while True:
print("------Info Gempa|>-")
print("-<| " + htmltext2[htmltext2.find("<Tanggal>"):htmltext2.find("</Tanggal>")].replace('<Tanggal>', "Tanggal ").replace('-', " "))
print("-<| " + htmltext2[htmltext2.find("<Jam>"):htmltext2.find("</Jam>")].replace('<Jam>', "Pukul "))
print("-<| " + htmltext2[htmltext2.find("<Magnitude>"):htmltext2.find("</Magnitude>")].replace('<Magnitude>', "Magnitude "))
print("-<| " + htmltext2[htmltext2.find("<Kedalaman>"):htmltext2.find("</Kedalaman>")].replace('<Kedalaman>', "Kedalaman "))
print("-<| " + htmltext2[htmltext2.find("<Potensi>"):htmltext2.find("</Potensi>")].replace('<Potensi>', ""))
print("----------------|>-")
print("")
print("---<|> BMKG ->X<- Banu - [" + Kabupaten + "] <|>---")
print("")
print("-| Info Suhu " + Kabupaten + " <0")
print("-| Info Kelembapan " + Kabupaten + " <1")
print("-| Info Cuaca " + Kabupaten + " <2")
print("-| Info Arah Angin " + Kabupaten + " <3")
print("-| Info Kecepatan Angin " + Kabupaten + " <4")
print("")
print("Silahkan dipilih dan ketik nomornya saja")
print("Antara 0 sampai 4")
print("")
Input = int(input('>nomor>'))
try:
if Input == 0:
print("----------------|>-")
print("---<| Info Suhu |>-")
print("----------------|>-")
data = str(htmltext[htmltext.find('parameter id="t" description="Temperature" type="hourly">'):htmltext.find('parameter id="t" description="Temperature" type="hourly">')+htmltext[htmltext.find('parameter id="t" description="Temperature" type="hourly">'):len(htmltext)].find("</parameter>")])
print("")
print(data.replace('parameter id="t" description="Temperature" type="hourly">', " Suhu Dalam Urutan jam mulai dari sekarang sampai +66 jam").replace('<timerange type="hourly" h="', "Dalam +").replace('" datetime=', " Jam , Waktu ").replace('"', "").replace('>', "").replace('</timerange', "").replace('<value unit=C', "*C ").replace('<value unit=F', "*F ").replace('</value', ""))
if Input == 1:
print("----------------------|>-")
print("---<| Info Kelembapan |>-")
print("----------------------|>-")
data = str(htmltext[htmltext.find('<parameter id="hu" description="Humidity" type="hourly">'):htmltext.find('<parameter id="hu" description="Humidity" type="hourly">')+htmltext[htmltext.find('<parameter id="hu" description="Humidity" type="hourly">'):len(htmltext)].find("</parameter>")])
print("")
print(data.replace('<timerange type="hourly" h="', "Dalam +").replace('" datetime=', " Jam , Waktu ").replace('"', "").replace('>', "").replace('<parameter id=hu description=Humidity type=hourly', " Kelembapan Dalam Urutan jam mulai dari sekarang sampai +66 jam").replace('<value unit=', "Kelembapan ").replace('</value', "").replace('</timerange', ""))
if Input == 2:
print("-----------------|>-")
print("---<| Info Cuaca |>-")
print("-----------------|>-")
data = str(htmltext[htmltext.find('<parameter id="weather" description="Weather" type="hourly">'):htmltext.find('<parameter id="weather" description="Weather" type="hourly">')+htmltext[htmltext.find('<parameter id="weather" description="Weather" type="hourly">'):len(htmltext)].find("</parameter>")])
print("")
print(data.replace('<timerange type="hourly" h="', "Dalam +").replace('" datetime=', " Jam , Waktu ").replace('"', "").replace('>', "").replace('<parameter id="weather" description="Weather" type="hourly">', " Cuaca Dalam Urutan jam mulai dari sekarang sampai +66 jam").replace('<value unit=', "Cuaca ").replace('</value', "").replace('</timerange', ""))
if Input == 3:
print("----------------------|>-")
print("---<| Info Arah Angin |>-")
print("----------------------|>-")
data = str(htmltext[htmltext.find('<parameter id="wd" description="Wind direction" type="hourly">'):htmltext.find('<parameter id="wd" description="Wind direction" type="hourly">')+htmltext[htmltext.find('<parameter id="wd" description="Wind direction" type="hourly">'):len(htmltext)].find("</parameter>")])
print("")
print(data)
if Input == 4:
print("---------------------------|>-")
print("---<| Info Kecepatan Angin |>-")
print("---------------------------|>-")
data = str(htmltext[htmltext.find('<parameter id="ws" description="Wind speed" type="hourly">'):htmltext.find('<parameter id="ws" description="Wind speed" type="hourly">')+htmltext[htmltext.find('<parameter id="ws" description="Wind speed" type="hourly">'):len(htmltext)].find("</parameter>")])
print("")
print(data)
except:
for x in range(100):
print("")
print("Mohon Maaf Nomor Tidak Falid")
except:
for x in range(100):
print("")
print("Mohon Maaf Nomor Tidak Falid")
print("")
print("---| Badan Meteorologi, Klimatologi, dan Geofisika |---")
print("")
print(" -| > python ->X<- Banu < |-")