List of disaster dispatches from the Sapporo City Fire Department [Python]

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 スクリーンショット 2016-02-01 10.57.49.png

At first glance, スクリーンショット 2016-02-01 06.49.05.png 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

List of disaster dispatches from the Sapporo City Fire Department [Python]
Existence from the viewpoint of Python
About the basics list of Python basics
Learning notes from the beginning of Python 1
Learning notes from the beginning of Python 2
Get the contents of git diff from python
[python] Check the elements of the list all, any
List of python modules
[Python] How to remove duplicate values from the list
The wall of changing the Django service from Python 2.7 to Python 3
Learn Nim with Python (from the beginning of the year).
Get the value of a specific key in a list from the dictionary type in the list with Python
[Python] Get the text of the law from the e-GOV Law API
[python] Get the list of classes defined in the module
Study from the beginning of Python Hour1: Hello World
the zen of Python
Get the return code of the Python script from bat
Python points from the perspective of a C programmer
I compared the speed of the reference of the python in list and the reference of the dictionary comprehension made from the in list.
[Python] Get the list of ExifTags names of Pillow library
[Python] Outputs all combinations of elements in the list
[Maya Python] Crush the contents of the script 2 ~ list Notes
Study from the beginning of Python Hour8: Using packages
Try to get the function list of Python> os package
[Maya Python] Crush the contents of the script 3 ~ List unknown Plugins
Different from the import type of python. from A import B meaning
Get the number of specific elements in a python list
Let's guess the development status of the city from the satellite image.
Python: Create a dictionary from a list of keys and values
What beginners learned from the basics of variables in python
2015-11-26 python> Display the function list of the module> import math> dir (math)
Extract the value closest to a value from a Python list element
Towards the retirement of Python2
Summary of Python3 list operations
About the ease of Python
[Python] Copy of multidimensional list
The Power of Pandas: Python
[Python] Display only the elements of the list side by side [Vertical, horizontal]
[Python] Try to graph from the image of Ring Fit [OCR]
[Python] Get the update date of a news article from HTML
[python] Get the rank of the values in List in ascending / descending order
From the introduction of JUMAN ++ to morphological analysis of Japanese with Python
python note: map -do the same for each element of the list
Important unit seen from the Python lecture materials of Kyoto University
[Python] A program that rotates the contents of the list to the left
Extension of Python by C or C ++ (when there are multiple arguments, when passing a list from the Python side)
[Completed version] Try to find out the number of residents in the town from the address list with Python
The story of Python and the story of NaN
First Python 3 ~ The beginning of repetition ~
pyenv-change the python version of virtualenv
Change the Python version of Homebrew
python / Make a dict from a list.
[Python] Understanding the potential_field_planning of Python Robotics
Review of the basics of Python (FizzBuzz)
Use the Flickr API from Python
Python3> List generation from iterable> list (range (5))
Learn the basics of Python ① Beginners
Comparing R, Python, SAS, SPSS from the perspective of European data scientists
Python> sys.path> List of strings indicating the path to search for modules
[Introduction to Python] How to sort the contents of a list efficiently with list sort
Get the list of packages for the specified user from the packages registered on PyPI