我是否使用正确的站点来查看原始JSON数据? [英] Am I using the correct site to view the raw JSON data?
问题描述
通过Google Chrome浏览器使用 NBA球队统计网络工具,我相信我找到了引导我访问原始JSON数据的站点
Using NBA Team Stats through Google Chrome's network tool, I believe I located the site to lead me to the raw JSON data
结果,我使用了以下URL:
As a result, I am using the following URL:
https://stats.nba.com/stats/leaguedashteamstats?Conference=&DateFrom=&DateTo=&Division=&GameScope=&GameSegment=&LastNGames=0&LeagueID=00&Location=&MeasureType=Base&Month=0&OpponentTeamID=0&Outcome=&PORound=0&PaceAdjust=N&PerMode=PerGame&Period=0&PlayerExperience=&PlayerPosition=&PlusMinus=N&Rank=N&Season=2019-20&SeasonSegment=&SeasonType=Regular+Season&ShotClockRange=&StarterBench=&TeamID=0&TwoWay=0&VsConference=&VsDivision=
但是,当我尝试访问上述站点时,它不会加载.这使我相信,也许我正在查看错误的信息以使我到达我要去的地方.有提示吗?
However, when I try to go to the above site, it does not load. This leads me to believe that perhaps I am looking at the wrong piece of information to get me to where I am trying to go. Any tips?
推荐答案
经过大量的挖掘,研究和试验&错误,我终于能够提出一个Python脚本(在Power BI内),该脚本可以完全满足我的需求.
After much digging, research, and trial & error, I was finally able to come up with a Python script (within Power BI) that would give me exactly what I needed.
import pandas as pd
import numpy
import requests
import json
headers = {'Accept': 'application/json, text/plain, */*','Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-US,en;q=0.9','Connection': 'keep-alive','Host': 'stats.nba.com',
'Referer': 'https://stats.nba.com/','Sec-Fetch-Mode': 'cors','Sec-Fetch-Site': 'same-origin',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/79.0.3945.130 Safari/537.36','x-nba-stats-origin': 'stats','x-nba-stats-token':
'true',}
url = 'https://stats.nba.com/stats/leaguedashplayerstats?College=&Conference=&Country=&DateFrom=&
Division=&DraftPick=&DraftYear=&GameScope=&GameSegment=&Height=&LastNGames=0&LeagueID=00&
Location=&MeasureType=Base&Month=0&OpponentTeamID=0&Outcome=&PORound=0&PaceAdjust=N&
PerMode=PerGame&Period=0&PlayerExperience=&PlayerPosition=&PlusMinus=N&Rank=N&Season=2019-20&
SeasonSegment=&SeasonType=Regular+Season&ShotClockRange=&StarterBench=&TeamID=0&TwoWay=0&
VsConference=&VsDivision=&Weight='
json = requests.get(url, headers=headers).json()
data = json['resultSets'][0]['rowSet']
columns = json['resultSets'][0]['headers']
PpgData = pd.DataFrame.from_records(data, columns=columns)
使用此脚本,我可以将所有JSON数据转换为正确格式的表.
Using this script allows me to convert all the JSON data to a table that will be properly formatted.
这篇关于我是否使用正确的站点来查看原始JSON数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!