Skip to content

Commit

Permalink
Fetch all pro players
Browse files Browse the repository at this point in the history
  • Loading branch information
neko314 committed Aug 3, 2023
1 parent 33df400 commit 1582435
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 843 deletions.
30 changes: 30 additions & 0 deletions collector.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'bundler/inline'

gemfile do
source 'https://rubygems.org'
gem 'nokogiri'
end

require 'open-uri'
require 'json'

File.open("./data/players.json", "w") do |f|
players = (1..10).map do |no|
doc = Nokogiri::HTML(URI.open("https://www.shogi.or.jp/player/pro/#{no}.html"))

name = doc.search(".nameTtl").search("span").search(".jp").text
break unless name

title = doc.search(".ico03").text
teacher = doc.search("td")[3].text # class, id では絞り込めない

{
no:,
name:,
title:,
teacher:,
}
end

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

0 comments on commit 1582435

Please sign in to comment.