-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
37 lines (31 loc) · 1020 Bytes
/
main.py
File metadata and controls
37 lines (31 loc) · 1020 Bytes
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
import requests
from bs4 import BeautifulSoup,Tag
import datetime
data = requests.get("http://www2.seattle.gov/fire/realtime911/getRecsForDatePub.asp?action=Today&incDate=&rad1=des")
soup = BeautifulSoup(data.content, "html.parser")
table = soup.findChildren('table')[0]
rows = table.findChildren(['th','tr'])
for row in rows:
cells = row.findChildren('td')
data = []
corresponding = []
for cell in cells:
data.append(cell.string)
corresponding.append(cell)
if data[0] == None or data[0] == "Date/Time":
pass
else:
topass = data[0].replace("/0", "/").replace(" 0"," ").replace(":0",":")
incidentActivity=None
if topass.startswith("0"):
topass=topass[1:]
date = datetime.datetime.strptime(topass,r"%m/%d/%Y %I:%M:%S %p")
incidentID = data[1]
priority = data[2]
apparatus = data[3]
address = data[4]
incidentType = data[5]
if corresponding[0]['class'] == ['active']:
incidentActivity = True
else:
incidentActivity = False