-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathHava Durumu.py
46 lines (36 loc) · 1.28 KB
/
Hava Durumu.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
# coding=utf-8
import re
import urllib.request
url = "https://www.havadurumu15gunluk.net/havadurumu/istanbul-hava-durumu-15-gunluk.html"
site = urllib.request.urlopen(url).read().decode('utf-8')
r_gunduz = '<td width="45"> (-?\d+)°C</td>'
r_gece = '<td width="45"> (-?\d+)°C</td>'
r_gun = '<td width="70" nowrap="nowrap">(.*)</td>'
r_tarih = '<td width="75" nowrap="nowrap">(.*)</td>'
r_aciklama = '<img src="/havadurumu/images/trans.gif" alt="İstanbul Hava durumu 15 günlük" width="1" height="1" />(.*)</div>'
comp_gunduz = re.compile(r_gunduz)
comp_gece = re.compile(r_gece)
comp_gun = re.compile(r_gun)
comp_tarih = re.compile(r_tarih)
comp_aciklama = re.compile(r_aciklama)
gunduz = []
gece = []
gun = []
tarih = []
aciklama = []
for i in re.findall(r_gunduz, site):
gunduz.append(i)
for i in re.findall(r_gece, site):
gece.append(i)
for i in re.findall(r_gun, site):
gun.append(i)
for i in re.findall(r_tarih, site):
tarih.append(i)
for i in re.findall(r_aciklama, site):
aciklama.append(i)
print("-" * 75)
print(" ISTANBUL HAVA DURUMU")
print("-" * 75)
for i in range(0, len(gun)):
print("{} {},\n\t\t\t\t\tgündüz: {} °C\tgece: {} °C\t{}".format(tarih[i], gun[i], gunduz[i], gece[i], aciklama[i]))
print("-" * 75)