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 #212 from covid19-miyazaki/staging
Release 2020-05-10 01:14:59 +0900
- Loading branch information
Showing
14 changed files
with
360 additions
and
419 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -51,4 +51,4 @@ | |
"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
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 |
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
Oops, something went wrong.