Slide 10
Slide 10 text
JS->HTML͕͜ΕͰࡁΜͩ
# νʔϜ͝ͱ, खͱख, ͚ͯอଘ
for team in teams
:
response = session.get(team['url']
)
response.html.render(timeout=60) # ίίͰJS͕HTMLʹϨϯμϦϯά͞ΕΔ
tbody = response.html.find('#team_batting > tbody', first=True
)
batters = players(tbody
)
write_csv(f'dataset/player_batter_{team["team"].replace(" ", "")}.csv', batters, fieldnames
)
tbody = response.html.find('#team_pitching > tbody', first=True
)
pitchers = players(tbody
)
write_csv(f'dataset/player_pitcher_{team["team"].replace(" ", "")}.csv', pitchers, fieldnames
)
https://github.com/Shinichi-Nakagawa/br-scraping-npb/blob/main/players.py#L28