Last active
June 20, 2022 03:40
-
-
Save YumNumm/42593b2cf7360f96623618481460c914 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import os | |
import datetime | |
def pga(now) -> str: | |
u1 = now.strftime('%Y%m%d') | |
u2 = now.strftime('%Y%m%d%H%M%S') | |
return "http://www.kmoni.bosai.go.jp/data/map_img/RealTimeImg/acmap_s/"+ str(u1) +"/" + str(u2) + ".acmap_s.gif" | |
def shindo(now) -> str: | |
u1 = now.strftime('%Y%m%d') | |
u2 = now.strftime('%Y%m%d%H%M%S') | |
return "http://www.kmoni.bosai.go.jp/data/map_img/RealTimeImg/jma_s/"+ str(u1) +"/" + str(u2) + ".jma_s.gif" | |
def eew_json(now) -> str: | |
u1 = now.strftime('%Y%m%d') | |
u2 = now.strftime('%Y%m%d%H%M%S') | |
return "http://www.kmoni.bosai.go.jp/webservice/hypo/eew/" + str(u2) + ".json" | |
def est_shindo(now) -> str: | |
u1 = now.strftime('%Y%m%d') | |
u2 = now.strftime('%Y%m%d%H%M%S') | |
return "http://www.kmoni.bosai.go.jp/data/map_img/EstShindoImg/eew/"+ str(u1) +"/" + str(u2) + ".eew.gif" | |
def download_from_url(url): | |
filename=os.path.basename(url) | |
r = requests.get(url, stream=True) | |
with open(filename, 'wb') as f: | |
for chunk in r.iter_content(chunk_size=1024): | |
if chunk: | |
f.write(chunk) | |
f.flush() | |
startDt = datetime.datetime(2022,6,19,15,8,00) | |
endDt = datetime.datetime(2022,6,19,15,11,00) | |
for i in range((endDt- startDt).seconds): | |
now = startDt + datetime.timedelta(seconds=i); | |
# Download | |
download_from_url(shindo(now)) | |
download_from_url(pga(now)) | |
download_from_url(eew_json(now)) | |
download_from_url(est_shindo(now)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment