Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve to generate JSON #120

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 86 additions & 76 deletions data/players.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@
"players": [
{
"name": "藤井聡太",
"title": "竜王(王位・叡王・王将・棋聖)",
"title": "竜王・名人(王位・叡王・棋王・王将・棋聖)",
"path": "/player/pro/307.html"
},
{
"name": "渡辺明",
"title": "名人(棋王)",
"path": "/player/pro/235.html"
},
{
"name": "永瀬拓矢",
"title": "王座",
Expand All @@ -35,6 +30,11 @@
"title": "九段(永世称号有資格者)",
"path": "/player/pro/183.html"
},
{
"name": "渡辺明",
"title": "九段(永世称号有資格者)",
"path": "/player/pro/235.html"
},
{
"name": "南芳一",
"title": "九段",
Expand Down Expand Up @@ -160,11 +160,6 @@
"title": "八段",
"path": "/player/pro/168.html"
},
{
"name": "中田宏樹",
"title": "八段",
"path": "/player/pro/173.html"
},
{
"name": "中川大輔",
"title": "八段",
Expand Down Expand Up @@ -295,15 +290,35 @@
"title": "八段",
"path": "/player/pro/188.html"
},
{
"name": "堀口一史座",
"title": "八段",
"path": "/player/pro/218.html"
},
{
"name": "中村太地",
"title": "八段",
"path": "/player/pro/261.html"
},
{
"name": "佐々木勇気",
"title": "八段",
"path": "/player/pro/280.html"
},
{
"name": "室岡克彦",
"title": "七段",
"title": "八段",
"path": "/player/pro/153.html"
},
{
"name": "堀口一史座",
"title": "七段",
"path": "/player/pro/218.html"
"name": "飯塚祐紀",
"title": "八段",
"path": "/player/pro/203.html"
},
{
"name": "村山慈明",
"title": "八段",
"path": "/player/pro/249.html"
},
{
"name": "所司和晴",
Expand All @@ -325,11 +340,6 @@
"title": "七段",
"path": "/player/pro/200.html"
},
{
"name": "飯塚祐紀",
"title": "七段",
"path": "/player/pro/203.html"
},
{
"name": "小林裕士",
"title": "七段",
Expand All @@ -350,11 +360,6 @@
"title": "七段",
"path": "/player/pro/190.html"
},
{
"name": "村山慈明",
"title": "七段",
"path": "/player/pro/249.html"
},
{
"name": "北島忠雄",
"title": "七段",
Expand Down Expand Up @@ -390,11 +395,6 @@
"title": "七段",
"path": "/player/pro/187.html"
},
{
"name": "中村太地",
"title": "七段",
"path": "/player/pro/261.html"
},
{
"name": "川上猛",
"title": "七段",
Expand Down Expand Up @@ -430,11 +430,6 @@
"title": "七段",
"path": "/player/pro/251.html"
},
{
"name": "佐々木勇気",
"title": "七段",
"path": "/player/pro/280.html"
},
{
"name": "西尾明",
"title": "七段",
Expand Down Expand Up @@ -545,6 +540,16 @@
"title": "七段",
"path": "/player/pro/306.html"
},
{
"name": "増田康宏",
"title": "七段",
"path": "/player/pro/297.html"
},
{
"name": "大橋貴洸",
"title": "七段",
"path": "/player/pro/308.html"
},
{
"name": "増田裕司",
"title": "六段",
Expand Down Expand Up @@ -595,11 +600,6 @@
"title": "六段",
"path": "/player/pro/258.html"
},
{
"name": "増田康宏",
"title": "六段",
"path": "/player/pro/297.html"
},
{
"name": "阪口悟",
"title": "六段",
Expand All @@ -610,16 +610,6 @@
"title": "六段",
"path": "/player/pro/259.html"
},
{
"name": "上野裕和",
"title": "六段",
"path": "/player/pro/238.html"
},
{
"name": "大橋貴洸",
"title": "六段",
"path": "/player/pro/308.html"
},
{
"name": "石井健太郎",
"title": "六段",
Expand Down Expand Up @@ -670,6 +660,26 @@
"title": "六段",
"path": "/player/pro/317.html"
},
{
"name": "渡辺和史",
"title": "六段",
"path": "/player/pro/319.html"
},
{
"name": "服部慎一郎",
"title": "六段",
"path": "/player/pro/322.html"
},
{
"name": "伊藤匠",
"title": "六段",
"path": "/player/pro/324.html"
},
{
"name": "本田奎",
"title": "六段",
"path": "/player/pro/315.html"
},
{
"name": "島本亮",
"title": "五段",
Expand Down Expand Up @@ -715,11 +725,6 @@
"title": "五段",
"path": "/player/pro/288.html"
},
{
"name": "本田奎",
"title": "五段",
"path": "/player/pro/315.html"
},
{
"name": "古森悠太",
"title": "五段",
Expand Down Expand Up @@ -765,26 +770,11 @@
"title": "五段",
"path": "/player/pro/311.html"
},
{
"name": "渡辺和史",
"title": "五段",
"path": "/player/pro/319.html"
},
{
"name": "伊藤匠",
"title": "五段",
"path": "/player/pro/324.html"
},
{
"name": "石川優太",
"title": "五段",
"path": "/player/pro/320.html"
},
{
"name": "服部慎一郎",
"title": "五段",
"path": "/player/pro/322.html"
},
{
"name": "折田翔吾",
"title": "五段",
Expand All @@ -795,9 +785,14 @@
"title": "五段",
"path": "/player/pro/313.html"
},
{
"name": "古賀悠聖",
"title": "五段",
"path": "/player/pro/326.html"
},
{
"name": "山本博志",
"title": "四段",
"title": "五段",
"path": "/player/pro/316.html"
},
{
Expand All @@ -810,11 +805,6 @@
"title": "四段",
"path": "/player/pro/325.html"
},
{
"name": "古賀悠聖",
"title": "四段",
"path": "/player/pro/326.html"
},
{
"name": "井田明宏",
"title": "四段",
Expand Down Expand Up @@ -854,6 +844,26 @@
"name": "齊藤裕也",
"title": "四段",
"path": "/player/pro/334.html"
},
{
"name": "小山怜央",
"title": "四段",
"path": "/player/pro/335.html"
},
{
"name": "小山直希",
"title": "四段",
"path": "/player/pro/336.html"
},
{
"name": "森本才跳",
"title": "四段",
"path": "/player/pro/337.html"
},
{
"name": "柵木幹太",
"title": "四段",
"path": "/player/pro/338.html"
}
]
}
6 changes: 3 additions & 3 deletions parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

players_nodes = doc.search("div .inner")
nodes = players_nodes.search("div .text")
File.open("players.json", "w") do |f|
File.open("./data/players.json", "w") do |f|
players = nodes.map do |node|
path = node.children.children.first.attributes["href"].value # path to detail
name = node.search(".ttl").children.children.text # name
Expand All @@ -22,8 +22,8 @@
name: "#{name}",
title: "#{title}",
path: "#{path}",
}.to_json
}
end

f.write({players: players}.to_json)
f.write(JSON.pretty_generate({ players: players }))
end