Since the Sapporo City Fire Department has released the data for the past few days on the web I will try to get it with Python. This time, I will get the data for that day The URL will be here. http://www.119.city.sapporo.jp/saigai/keihon.html
Eventually it will be like this
At first glance, You won't need it when you get it here. "Return to top" Can normally be done by deleting a string. Below that "To yesterday (31st) minutes" Can be done by decrementing the date by -1 and deleting it as a string.
Get dispatch status.py
#coding: utf-8
import urllib2, re, datetime
def GET_status():
GET_URL = "http://www.119.city.sapporo.jp/saigai/keihon.html"
req = urllib2.Request(GET_URL)
response = urllib2.urlopen(req)
the_page = response.read().decode('shift_jis')
tabu_pY_ = re.sub("<.*?>","",the_page)
one = tabu_pY_.replace(u"Return to top", "")
try:
todaydetail = datetime.date.today() -datetime.timedelta(1)
return one.replace(u"yesterday(%s day)To minutes" % todaydetail.strftime("%d"), "")
except Exception, e:
print e
if __name__ == "__main__":
i = GET_status()
print i
Recommended Posts