0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ゆるふわに始めるバスケの分析

Last updated at Posted at 2018-02-22

スポナビのボックススコアにpandasのread_html()を使うことで簡単にデータを取得できます

環境

docker上にjupyterコンテナを起動すると楽

$ docker -v
Docker version 17.12.0-ce, build c97c6d6

$ docker-compose -v
docker-compose version 1.18.0, build 8dd22a9

$ cat docker-compose.yml
version: "3"
services:
  jupyter:
    image: jupyter/datascience-notebook
    ports:
      - "8888:8888"
    volumes:
      - jupyter_data:/opt/conda
      - jovyan_data:/home/jovyan
    container_name: jupyter
volumes:
  jupyter_data:
  jovyan_data:

ボックススコアの取得

スポナビのバスケページからボックススコアのURLを入手します
2017-18シーズン現在では
http://sportsnavi.ht.kyodo-d.jp/basketball/stats/[b1|b2|b3]/score/[試合通し番号]/box/[h|a]/
最後の[h|a]でホームチーム、アウェイチームのボックススコアが選択できます

pandasのread_html()で取得

import pandas as pd
tables = pd.read_html('http://sportsnavi.ht.kyodo-d.jp/basketball/stats/b1/score/1818/box/a/', flavor='bs4')

tables[0]で得点が、tables[1]で選手別の成績が取得できる

bleague-01.png
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?