This repository has been archived by the owner on Jul 17, 2024. It is now read-only.
forked from Tokyo-Metro-Gov/covid19
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from koogawa/development
陽性患者数推移、陽性患者の属性も自動更新したい
- Loading branch information
Showing
5 changed files
with
150 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,54 @@ | ||
{"newsItems":[{"date":"2020年4月11日","url":"https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/covid19_20200411.html","text":"新型コロナウイルス感染症患者(第17例目)の発生について(第一報)"},{"date":"2020年4月8日","url":"https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/covid19_20200408.html","text":"新型コロナウイルス感染症患者(第13~16例目)の発生について(第一報)"},{"date":"2020年4月7日","url":"https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/20200407.html","text":"新型コロナウイルス感染症患者(第12例目)の発生について(第一報)"},{"date":"2020年4月7日","url":"https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/covid19_20200304.html","text":"新型コロナウイルス感染症患者(第1例目)の発生について(続報)"},{"date":"2020年4月6日","url":"https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/covid19_20200406.html","text":"新型コロナウイルス感染症患者(第11例目)の発生について(第一報)"},{"date":"2020年4月5日","url":"https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/covid19_20200405.html","text":"新型コロナウイルス感染症患者(第9、10例目)の発生について(第一報)"},{"date":"2020年4月4日","url":"https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/covid19_20200404.html","text":"新型コロナウイルス感染症患者(8例目)の発生について(第一報)"},{"date":"2020年4月4日","url":"https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/covid19_20200403.html","text":"新型コロナウイルス感染症患者(4例目)の発生について(続報)"},{"date":"2020年4月3日","url":"https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/covid19_20200403-2.html","text":"新型コロナウイルス感染症患者(5~7例目)の発生について(第一報)"},{"date":"2020年4月3日","url":"https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/covid19_20200317.html","text":"新型コロナウイルス感染症患者(2例目、3例目)の発生について(続報)"}]} | ||
{ | ||
"newsItems": [ | ||
{ | ||
"date": "2020年4月11日", | ||
"url": "https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/covid19_20200411.html", | ||
"text": "新型コロナウイルス感染症患者(第17例目)の発生について(第一報)" | ||
}, | ||
{ | ||
"date": "2020年4月8日", | ||
"url": "https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/covid19_20200408.html", | ||
"text": "新型コロナウイルス感染症患者(第13~16例目)の発生について(第一報)" | ||
}, | ||
{ | ||
"date": "2020年4月7日", | ||
"url": "https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/20200407.html", | ||
"text": "新型コロナウイルス感染症患者(第12例目)の発生について(第一報)" | ||
}, | ||
{ | ||
"date": "2020年4月7日", | ||
"url": "https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/covid19_20200304.html", | ||
"text": "新型コロナウイルス感染症患者(第1例目)の発生について(続報)" | ||
}, | ||
{ | ||
"date": "2020年4月6日", | ||
"url": "https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/covid19_20200406.html", | ||
"text": "新型コロナウイルス感染症患者(第11例目)の発生について(第一報)" | ||
}, | ||
{ | ||
"date": "2020年4月5日", | ||
"url": "https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/covid19_20200405.html", | ||
"text": "新型コロナウイルス感染症患者(第9、10例目)の発生について(第一報)" | ||
}, | ||
{ | ||
"date": "2020年4月4日", | ||
"url": "https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/covid19_20200404.html", | ||
"text": "新型コロナウイルス感染症患者(8例目)の発生について(第一報)" | ||
}, | ||
{ | ||
"date": "2020年4月4日", | ||
"url": "https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/covid19_20200403.html", | ||
"text": "新型コロナウイルス感染症患者(4例目)の発生について(続報)" | ||
}, | ||
{ | ||
"date": "2020年4月3日", | ||
"url": "https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/covid19_20200403-2.html", | ||
"text": "新型コロナウイルス感染症患者(5~7例目)の発生について(第一報)" | ||
}, | ||
{ | ||
"date": "2020年4月3日", | ||
"url": "https://www.pref.miyazaki.lg.jp/kohosenryaku/kenko/hoken/covid19_20200317.html", | ||
"text": "新型コロナウイルス感染症患者(2例目、3例目)の発生について(続報)" | ||
} | ||
] | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
require 'selenium-webdriver' | ||
require 'date' | ||
|
||
today = Date.today.strftime("%Y/%m/%d") | ||
driver = Selenium::WebDriver.for :remote, desired_capabilities: :chrome, url: "http://#{ENV['SELENIUM_HOST']}:4444/wd/hub" | ||
|
||
# 最新ニュースのURL取得 | ||
driver.navigate.to(ENV['URL']) | ||
list_table = driver.find_element(:class => "list_table") | ||
urls = list_table.find_elements(:tag_name => "a") | ||
url = urls[0].attribute("href") | ||
|
||
# 最新ニュースをスクレイピング | ||
driver.navigate.to(url) | ||
uls = driver.find_elements(:class => "noicon") | ||
count = uls.length - 1 | ||
datas = [] | ||
for i in 0..count do | ||
data = { "リリース日" => today, "退院" => "入院中", "date" => today } | ||
ul = uls[i] | ||
|
||
address = ul.text.match(/居住地(.+)/) | ||
if address | ||
data["居住地"] = address[1] | ||
else | ||
next | ||
end | ||
|
||
age = ul.text.match(/年齢(.+)/) | ||
if age | ||
data["年代"] = age[1] | ||
else | ||
next | ||
end | ||
|
||
gender = ul.text.match(/性別(.+)/) | ||
if gender | ||
data["性別"] = gender[1] | ||
else | ||
next | ||
end | ||
|
||
datas.push(data) | ||
end | ||
|
||
data_count = datas.length | ||
|
||
data_hash = {} | ||
File.open("data/data.json") do |file| | ||
data_hash = JSON.load(file) | ||
end | ||
|
||
# data.json を更新 | ||
data_hash["lastUpdate"] = today | ||
data_hash["patients"]["date"] = today | ||
data_hash["patients"]["data"].concat(datas) | ||
data_hash["main_summary"]["children"][0]["value"] = data_hash["main_summary"]["children"][0]["value"] + data_count | ||
data_hash["main_summary"]["children"][0]["children"][0]["value"] = data_hash["main_summary"]["children"][0]["children"][0]["value"] + data_count | ||
data_hash["main_summary"]["children"][0]["children"][0]["children"][0]["value"] = data_hash["main_summary"]["children"][0]["children"][0]["children"][0]["value"] + data_count | ||
data_hash["patients_summary"]["data"].push({ "日付" => today, "小計" => data_count }) | ||
|
||
data_json = JSON.pretty_generate(data_hash, {:indent => " "}) | ||
File.open("data/data.json", mode = "w") { |f| | ||
f.write(data_json) | ||
} | ||
|
||
exit |