LoginSignup
52
44

More than 5 years have passed since last update.

[Python]イカリング2のJsonを取得してみた

Last updated at Posted at 2017-07-26

イカリング2のデータをPCのブラウザで見る方法が上がっていたため,それを参考にした.
【スプラトゥーン2】イカリング2の戦績データをPCブラウザで無理矢理閲覧する

環境

Python 3.6.1

Cookieの取得

今記事を書いていたら,分かりやすいものを発見した.
イカリング2をPCブラウザで見れる方法があるらしいのでやってみた

このリンクの記載の方法で,Cookieの値をメモする.

コード

ikaring.py
import urllib
from urllib.request import build_opener, HTTPCookieProcessor
from urllib.parse import urlencode
import http
from http.cookiejar import CookieJar
import codecs

def printJson(url): # Jsonを取得してprint
    cookie = "iksm_session=メモしたCookie値"
    opener = build_opener(HTTPCookieProcessor(CookieJar()))
    opener.addheaders.append(("Cookie", cookie))
    res = opener.open(url)
    print (codecs.decode(res.read(), 'unicode-escape'))

printJson("https://app.splatoon2.nintendo.net/api/data/stages") # 今のステージの取得
#printJson("https://app.splatoon2.nintendo.net/api/festivals/active") # フェスの情報の取得?
#printJson("https://app.splatoon2.nintendo.net/api/schedules") # スケジュールの取得
#printJson("https://app.splatoon2.nintendo.net/api/records") # 今の装備や塗った面積等の取得
#printJson("https://app.splatoon2.nintendo.net/api/timeline") # フレンドの状況?
#printJson("https://app.splatoon2.nintendo.net/api/onlineshop/merchandises") # ギアショップの情報
#printJson("https://app.splatoon2.nintendo.net/api/results/110") # 各バトルのデータ


こんな感じでJsonで返ってくるので,いろいろ加工しやすい.

他にも取得できるデータがあるかもしれない.

https://app.splatoon2.nintendo.net/api/results/110の110が各バトルに該当する.
109番目のバトルのデータにアクセスしたい場合は,https://app.splatoon2.nintendo.net/api/results/109とすれば良い.
人によってバトル回数・直近50バトルが異なることに注意.

最新の50バトルまでしか履歴を見ることができないため,各バトルのデータを記録するのに活用できそうだ.
自分だけでなく,仲間・相手のギアも見れるため,たくさんデータを集めれば得意/苦手なシチュエーション等のデータマイニングもできそう.

52
44
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
52
44