[Python] I tried to get Json of squid ring 2

Since the method of viewing the data of squid ring 2 on a PC browser has been improved, I referred to it. [Splatoon 2] Forcibly browse the battle record data of Squid Ring 2 with a PC browser

environment

Python 3.6.1

Get cookies

When I was writing this article, I found something that was easy to understand. There seems to be a way to see Squid Ring 2 on a PC browser, so I tried it

Make a note of the cookie value using the method described in this link.

code

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): #Get Json and print
    cookie = "iksm_session=Noted cookie value"
    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") #Get the current stage
#printJson("https://app.splatoon2.nintendo.net/api/festivals/active") #Get information about festivals?
#printJson("https://app.splatoon2.nintendo.net/api/schedules") #Get schedule
#printJson("https://app.splatoon2.nintendo.net/api/records") #Acquisition of current equipment and painted area
#printJson("https://app.splatoon2.nintendo.net/api/timeline") #Friend status?
#printJson("https://app.splatoon2.nintendo.net/api/onlineshop/merchandises") #Gear shop information
#printJson("https://app.splatoon2.nintendo.net/api/results/110") #Data for each battle
Since it is returned in Json like this, it is easy to process in various ways.

There may be other data that can be obtained.

110 of https://app.splatoon2.nintendo.net/api/results/110 corresponds to each battle. If you want to access the data of the 109th battle, you can do https://app.splatoon2.nintendo.net/api/results/109. Note that the number of battles and the last 50 battles differ depending on the person.

Since you can only see the history of the latest 50 battles, it seems that you can use it to record the data of each battle. Since you can see not only yourself but also the gears of your friends and opponents, if you collect a lot of data, you will be able to perform data mining such as situations that you are good at / not good at.

Recommended Posts

[Python] I tried to get Json of squid ring 2
I tried to get the authentication code of Qiita API with Python.
I tried to get the movie information of TMDb API with Python
I tried to summarize how to use matplotlib of python
I tried to get started with blender python script_Part 01
I tried to get started with blender python script_Part 02
I tried to summarize the string operations of Python
I tried to touch Python (installation)
I tried to find the entropy of the image with python
I tried to get the location information of Odakyu Bus
I tried "How to get a method decorated in Python"
[Python] I tried to visualize the follow relationship of Twitter
I tried to implement blackjack of card game in Python
I tried to summarize Python exception handling
I tried to implement PLSA in Python
I tried to get a database of horse racing using Pandas
I tried to implement permutation in Python
I tried to get the index of the list using the enumerate function
I tried to get started with Hy
I tried to make a regular expression of "amount" using Python
I tried to make a regular expression of "time" using Python
I tried to implement PLSA in Python 2
[Python] A memo that I tried to get started with asyncio
Python3 standard input I tried to summarize
I tried to create a list of prime numbers with python
I tried to make a regular expression of "date" using Python
I tried to fix "I tried stochastic simulation of bingo game with Python"
I tried to get a list of AMI Names using Boto3
I tried to implement PPO in Python
[Python] I tried to calculate TF-IDF steadily
I tried to touch Python (basic syntax)
I tried to improve the efficiency of daily work with Python
[Python] I tried to get various information using YouTube Data API!
I tried to automatically collect images of Kanna Hashimoto with Python! !!
PhytoMine-I tried to get the genetic information of plants with Python
I tried to get the batting results of Hachinai using image processing
I tried to develop a Formatter that outputs Python logs in JSON
(Python) I tried to analyze 1 million hands ~ I tried to estimate the number of AA ~
I tried to verify and analyze the acceleration of Python by Cython
I tried to streamline the standard role of new employees with Python
I tried to get the RSS of the top song of the iTunes store automatically
[Lambda] I tried to incorporate an external module of python via S3
I tried to implement a card game of playing cards in Python
[Python / DynamoDB / boto3] List of operations I tried
I tried to notify slack of Redmine update
I tried to get an image by scraping
I tried to find 100 million digits of pi
I tried to touch the API of ebay
I tried to correct the keystone of the image
I tried to output LLVM IR with Python
I tried to implement TOPIC MODEL in Python
I tried to automate sushi making with python
I want to get League of Legends data ②
How to get dictionary type elements of Python 2.7
I tried to implement selection sort in python
I want to get League of Legends data ①
I tried to predict the price of ETF
I tried to vectorize the lyrics of Hinatazaka46!
I tried Python> autopep8
I tried to debug.
I tried to get and analyze the statistical data of the new corona with Python: Data of Johns Hopkins University