気象衛星の画像を定期的に集めるのにいい方法がないかと考え、pythonでコードを作り、一日一回動かす、みたいなことを考えた。
でかけたときでも勝手に回収できるようにlinuxでも動かせるようにしておくといいかも。
以下のコードで一日分のデータを集められる。日付が変わった頃合いにこれを動かせば前日分のデータを集めきれる。
# -*- coding: utf-8 -*- """ Created on Sat Aug 8 14:10:25 2020 @author: m """ root_url = "http://www.jma.go.jp/jp/radnowc/imgs/radar/" area_codes = ["000","201","202","203","204","205","206","207","208","209","210","211","212","213","214","215","216","217","218","219"] hour_list = ["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"] min_list = ["00","05","10","15","20","25","30","35","40","45","50","55"] import urllib3 import datetime import os def download(url, file_name): connection_pool = urllib3.PoolManager() resp = connection_pool.request('GET', url) f = open(file_name,'wb') f.write(resp.data) f.close resp.release_conn() now = datetime.date.today().strftime("%Y%m%d") yesterday = datetime.date.today() - datetime.timedelta(days=1) print(yesterday.strftime("%Y%m%d")) i=0 download("http://www.jma.go.jp/jp/radnowc/imgs/radar/210/202008081425-00.png","testtest.png") for areas in area_codes: new_path = areas +"\\" + yesterday.strftime("%m%d") if not os.path.isdir(new_path): print(new_path) os.mkdir(new_path) for hours in hour_list: for mins in min_list: i += 1; for areas in area_codes: url = root_url + areas +"/" + yesterday.strftime("%Y%m%d")+ hours + mins + "-00.png" print(url) print(areas +"\\" + yesterday.strftime("%m%d") + "\\{:04d}".format(i)) download(url, areas +"\\" + yesterday.strftime("%m%d") + "\\{:04d}".format(i)+".png")