I'm having a problem where i can scrape data from a website by using the java pathing. I'm trying to scrape from Rocket League Tracker.
here's my code:
import requests
import re
import json
import math
def rankGetter():
trackerLink = 'https://rocketleague.tracker.network/rocket-league/profile/epic/DirectPanda/overview'
# now we have the tracker link we're going to scrape the website
# all the HTML of the site is now in result
result = requests.get(trackerLink)
# checker to make sure the user used the correct information
if result.status_code == 400:
print('profile not found')
else:
# Extract everything needed to render the current page. Data is stored as Json in the
# JavaScript variable: window.__INITIAL_STATE__={"route":{"path":"\u0 ... }};
json_string = re.search(r"window.__INITIAL_STATE__\s?=\s?(\{.*?\});", result.text).group(1)
# convert text string to structured json data
rocketleague = json.loads(json_string)
# Save structured json data to a text file that helps you orient yourself and pick
# the parts you are interested in.
with open('rocketleague_json_data.txt', 'w') as outfile:
outfile.write(json.dumps(rocketleague, indent=4, sort_keys=True))
The error is the text doc made doesn't have the ranks I want anymore.
"stats": {
"standardLeaderboardLeaders": {},
"standardLeaderboards": [],
"standardPlayers": {},
"standardTitles": {}
},
**"stats-v2": {
"segments": {},
"standardProfileMatches": {},
"standardProfileSummaries": {},
"standardProfiles": {},
"standardProfilesHistory": {},
"standardSessions": {},
"subscriptions": {}
},**
"titles": {
"currentTitle": {
"name": "Rocket League",
"platforms": [
The Ranks should be under stats-V2 but as you can see its empty now.
whats happening and how do i fix it? I was able to get ranks for a week but all the sudden it stopped working today.
Seems that the data are loaded from external URL:
import json
import requests
url = "https://api.tracker.gg/api/v2/rocket-league/standard/profile/epic/DirectPanda"
headers = {
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0"
}
data = requests.get(url, headers=headers).json()
print(json.dumps(data, indent=4))
Prints:
{
"data": {
"platformInfo": {
"platformSlug": "epic",
"platformUserId": null,
"platformUserHandle": "DirectPanda",
"platformUserIdentifier": "DirectPanda",
"avatarUrl": null,
"additionalParameters": null
},
"userInfo": {
"userId": null,
"isPremium": false,
"isVerified": false,
"isInfluencer": false,
"isPartner": false,
"countryCode": null,
"customAvatarUrl": null,
"customHeroUrl": null,
"socialAccounts": [],
"pageviews": 592,
"isSuspicious": null
},
"metadata": {
"lastUpdated": {
"value": "2021-04-22T17:39:42.277-04:00",
"displayValue": "2021-04-22T21:39:42.2770000+00:00"
},
"playerId": 16603481,
"currentSeason": 17
},
"segments": [
{
"type": "overview",
"attributes": {},
"metadata": {
"name": "Lifetime"
},
"expiryDate": "0001-01-01T00:00:00+00:00",
"stats": {
"wins": {
"rank": 30357,
"percentile": 98.3,
"displayName": "Wins",
"displayCategory": "Performance",
"category": "performance",
"metadata": {},
"value": 4985,
"displayValue": "4,985",
"displayType": "Number"
},
"goals": {
"rank": 23698,
"percentile": 98.7,
"displayName": "Goals",
"displayCategory": "Performance",
"category": "performance",
"metadata": {},
"value": 14363,
"displayValue": "14,363",
"displayType": "Number"
},
"mVPs": {
"rank": 35646,
"percentile": 98.0,
"displayName": "MVPs",
"displayCategory": "Performance",
"category": "performance",
"metadata": {},
"value": 2093,
"displayValue": "2,093",
"displayType": "Number"
},
"saves": {
"rank": 30864,
"percentile": 98.3,
"displayName": "Saves",
"displayCategory": "Performance",
"category": "performance",
"metadata": {},
"value": 9231,
"displayValue": "9,231",
"displayType": "Number"
},
"assists": {
"rank": 29228,
"percentile": 98.4,
"displayName": "Assists",
"displayCategory": "Performance",
"category": "performance",
"metadata": {},
"value": 4763,
"displayValue": "4,763",
"displayType": "Number"
},
"shots": {
"rank": 24596,
"percentile": 98.6,
"displayName": "Shots",
"displayCategory": "Performance",
"category": "performance",
"metadata": {},
"value": 29139,
"displayValue": "29,139",
"displayType": "Number"
},
"goalShotRatio": {
"rank": 1409320,
"percentile": 15.0,
"displayName": "Goal Shot Ratio",
"displayCategory": "Performance",
"category": "performance",
"metadata": {},
"value": 49.29132777377398,
"displayValue": "49.3",
"displayType": "NumberPrecision1"
},
"score": {
"rank": 28260,
"percentile": 98.4,
"displayName": "TRN Score",
"displayCategory": "General",
"category": "general",
"metadata": {},
"value": 2398222.83,
"displayValue": "2,398,222.8",
"displayType": "NumberPrecision1"
},
"seasonRewardLevel": {
"rank": null,
"percentile": 85.0,
"displayName": "Season Reward Level",
"displayCategory": "General",
"category": "general",
"metadata": {
"iconUrl": "https://trackercdn.com/cdn/tracker.gg/rocket-league/ranks/s4-13.png",
"rankName": "Diamond"
},
"value": 5,
"displayValue": "5",
"displayType": "Number"
},
"seasonRewardWins": {
"rank": null,
"percentile": 95.8,
"displayName": "Season Reward Wins",
"displayCategory": "General",
"category": "general",
"metadata": {},
"value": 9,
"displayValue": "9",
"displayType": "Number"
}
}
},
{
"type": "playlist",
"attributes": {
"playlistId": 0,
"season": 17
},
"metadata": {
"name": "Un-Ranked"
},
"expiryDate": "0001-01-01T00:00:00+00:00",
"stats": {
"tier": {
"rank": null,
"percentile": null,
"displayName": "Matches",
"displayCategory": "General",
"category": "general",
"metadata": {
"iconUrl": "https://trackercdn.com/cdn/tracker.gg/rocket-league/ranks/s4-0.png",
"name": "Unranked"
},
"value": 0,
"displayValue": "0",
"displayType": "Number"
},
"division": {
"rank": null,
"percentile": null,
"displayName": "Matches",
"displayCategory": "General",
"category": "general",
"metadata": {
"name": "Division I"
},
"value": 0,
"displayValue": "0",
"displayType": "Number"
},
"matchesPlayed": {
"rank": null,
"percentile": null,
"displayName": "Matches",
"displayCategory": "Performance",
"category": "performance",
"metadata": {},
"value": 0,
"displayValue": "0",
"displayType": "Number"
},
"winStreak": {
"rank": null,
"percentile": null,
"displayName": "WinStreak",
"displayCategory": "Performance",
"category": "performance",
"metadata": {
"type": "win"
},
"value": 0,
"displayValue": "0",
"displayType": "Number"
},
"rating": {
"rank": 215152,
"percentile": 90.0,
"displayName": "Rating",
"displayCategory": "Skill",
"category": "skill",
"metadata": {},
"value": 1597,
"displayValue": "1,597",
"displayType": "Number"
}
}
},
{
"type": "playlist",
"attributes": {
"playlistId": 10,
"season": 17
},
"metadata": {
"name": "Ranked Duel 1v1"
},
"expiryDate": "0001-01-01T00:00:00+00:00",
"stats": {
"tier": {
"rank": null,
"percentile": 98.2,
"displayName": "Matches",
"displayCategory": "General",
"category": "general",
"metadata": {
"iconUrl": "https://trackercdn.com/cdn/tracker.gg/rocket-league/ranks/s4-16.png",
"name": "Champion I"
},
"value": 16,
"displayValue": "16",
"displayType": "Number"
},
"division": {
"rank": null,
"percentile": 88.0,
"displayName": "Matches",
"displayCategory": "General",
"category": "general",
"metadata": {
"deltaDown": 13,
"deltaUp": 6,
"name": "Division III"
},
"value": 2,
"displayValue": "2",
"displayType": "Number"
},
"matchesPlayed": {
"rank": null,
"percentile": 57.0,
"displayName": "Matches",
"displayCategory": "Performance",
"category": "performance",
"metadata": {},
"value": 2,
"displayValue": "2",
"displayType": "Number"
},
"winStreak": {
"rank": null,
"percentile": 60.0,
"displayName": "WinStreak",
"displayCategory": "Performance",
"category": "performance",
"metadata": {
"type": "win"
},
"value": 1,
"displayValue": "1",
"displayType": "Number"
},
"rating": {
"rank": 101541,
"percentile": 96.1,
"displayName": "Rating",
"displayCategory": "Skill",
"category": "skill",
"metadata": {},
"value": 1031,
"displayValue": "1,031",
"displayType": "Number"
}
}
},
{
"type": "playlist",
"attributes": {
"playlistId": 11,
"season": 17
},
"metadata": {
"name": "Ranked Doubles 2v2"
},
"expiryDate": "0001-01-01T00:00:00+00:00",
"stats": {
"tier": {
"rank": null,
"percentile": 87.0,
"displayName": "Matches",
"displayCategory": "General",
"category": "general",
"metadata": {
"iconUrl": "https://trackercdn.com/cdn/tracker.gg/rocket-league/ranks/s4-16.png",
"name": "Champion I"
},
"value": 16,
"displayValue": "16",
"displayType": "Number"
},
"division": {
"rank": null,
"percentile": 90.0,
"displayName": "Matches",
"displayCategory": "General",
"category": "general",
"metadata": {
"deltaDown": 15,
"deltaUp": 3,
"name": "Division IV"
},
"value": 3,
"displayValue": "3",
"displayType": "Number"
},
"matchesPlayed": {
"rank": null,
"percentile": 80.0,
"displayName": "Matches",
"displayCategory": "Performance",
"category": "performance",
"metadata": {},
"value": 40,
"displayValue": "40",
"displayType": "Number"
},
"winStreak": {
"rank": null,
"percentile": 34.0,
"displayName": "WinStreak",
"displayCategory": "Performance",
"category": "performance",
"metadata": {
"type": "loss"
},
"value": 1,
"displayValue": "-1",
"displayType": "Number"
},
"rating": {
"rank": 311789,
"percentile": 89.0,
"displayName": "Rating",
"displayCategory": "Skill",
"category": "skill",
"metadata": {},
"value": 1177,
"displayValue": "1,177",
"displayType": "Number"
}
}
},
{
"type": "playlist",
"attributes": {
"playlistId": 13,
"season": 17
},
"metadata": {
"name": "Ranked Standard 3v3"
},
"expiryDate": "0001-01-01T00:00:00+00:00",
"stats": {
"tier": {
"rank": null,
"percentile": 96.0,
"displayName": "Matches",
"displayCategory": "General",
"category": "general",
"metadata": {
"iconUrl": "https://trackercdn.com/cdn/tracker.gg/rocket-league/ranks/s4-17.png",
"name": "Champion II"
},
"value": 17,
"displayValue": "17",
"displayType": "Number"
},
"division": {
"rank": null,
"percentile": 79.0,
"displayName": "Matches",
"displayCategory": "General",
"category": "general",
"metadata": {
"deltaDown": 7,
"deltaUp": 27,
"name": "Division III"
},
"value": 2,
"displayValue": "2",
"displayType": "Number"
},
"matchesPlayed": {
"rank": null,
"percentile": 97.8,
"displayName": "Matches",
"displayCategory": "Performance",
"category": "performance",
"metadata": {},
"value": 95,
"displayValue": "95",
"displayType": "Number"
},
"winStreak": {
"rank": null,
"percentile": 16.0,
"displayName": "WinStreak",
"displayCategory": "Performance",
"category": "performance",
"metadata": {
"type": "loss"
},
"value": 2,
"displayValue": "-2",
"displayType": "Number"
},
"rating": {
"rank": 122500,
"percentile": 95.8,
"displayName": "Rating",
"displayCategory": "Skill",
"category": "skill",
"metadata": {},
"value": 1255,
"displayValue": "1,255",
"displayType": "Number"
}
}
},
...
I am trying to get a section of the fortnite API that is in lifeTimeStats and the kills value. I can't figure out how to just get the kills and not the whole API.
import requests
headers = {'TRN-Api-Key': '52f2fbde-018d-47b5-9c7d-99990c0d3507'}
url = 'https://api.fortnitetracker.com/v1/profile/pc/loopisjones'
r = requests.get(url, headers = headers)
test = r.text
print test
These are the results there are too many character to enter the whole thing but I want to just get the kills from the "lifeTimeStats":
{
"accountId": "649eb4a8-584e-4896-adc9-66569ee92139",
"platformId": 3,
"platformName": "pc",
"platformNameLong": "PC",
"epicUserHandle": "loopisjones",
"stats": {
"p2": {
"trnRating": {
"label": "TRN Rating",
"field": "TRNRating",
"category": "Rating",
"valueInt": 1111,
"value": "1111",
"rank": 2507075,
"displayValue": "1,111"
},
"score": {
"label": "Score",
"field": "Score",
"category": "General",
"valueInt": 97533,
"value": "97533",
"rank": 279372,
"displayValue": "97,533"
},
"top1": {
"label": "Wins",
"field": "Top1",
"category": "Tops",
"valueInt": 3,
"value": "3",
"rank": 978112,
"percentile": 48.0,
"displayValue": "3"
},
"top3": {
"label": "Top 3",
"field": "Top3",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top5": {
"label": "Top 5",
"field": "Top5",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top6": {
"label": "Top 6",
"field": "Top6",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top10": {
"label": "Top 10",
"field": "Top10",
"category": "Tops",
"valueInt": 56,
"value": "56",
"rank": 577434,
"percentile": 6.0,
"displayValue": "56"
},
"top12": {
"label": "Top 12",
"field": "Top12",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top25": {
"label": "Top 25",
"field": "Top25",
"category": "Tops",
"valueInt": 176,
"value": "176",
"rank": 318099,
"percentile": 3.2,
"displayValue": "176"
},
"kd": {
"label": "K/d",
"field": "KD",
"category": "General",
"valueDec": 1.04,
"value": "1.04",
"rank": 1484862,
"percentile": 42.0,
"displayValue": "1.04"
},
"winRatio": {
"label": "Win %",
"field": "WinRatio",
"category": "General",
"valueDec": 0.5,
"value": "0.5",
"rank": 1549361,
"percentile": 61.0,
"displayValue": "0.50"
},
"matches": {
"label": "Matches",
"field": "Matches",
"category": "General",
"valueInt": 658,
"value": "658",
"rank": 277505,
"percentile": 12.0,
"displayValue": "658"
},
"kills": {
"label": "Kills",
"field": "Kills",
"category": "General",
"valueInt": 680,
"value": "680",
"rank": 470461,
"percentile": 18.0,
"displayValue": "680"
},
"kpg": {
"label": "Kills Per Match",
"field": "KPG",
"category": "General",
"valueDec": 1.03,
"value": "1.03",
"rank": 1484405,
"percentile": 41.0,
"displayValue": "1.03"
},
"avgTimePlayed": {
"label": "Avg Match Time",
"field": "AvgTimePlayed",
"category": "General",
"valueDec": 323.43,
"value": "323.43",
"rank": 1535727,
"displayValue": "5m 23s"
},
"scorePerMatch": {
"label": "Score per Match",
"field": "ScorePerMatch",
"category": "General",
"valueDec": 148.23,
"value": "148.23",
"rank": 1272686,
"percentile": 53.0,
"displayValue": "148.23"
}
},
"p10": {
"trnRating": {
"label": "TRN Rating",
"field": "TRNRating",
"category": "Rating",
"valueInt": 1200,
"value": "1200",
"displayValue": "1,200"
},
"score": {
"label": "Score",
"field": "Score",
"category": "General",
"valueInt": 46764,
"value": "46764",
"rank": 1123263,
"displayValue": "46,764"
},
"top1": {
"label": "Wins",
"field": "Top1",
"category": "Tops",
"valueInt": 3,
"value": "3",
"rank": 1383465,
"percentile": 48.0,
"displayValue": "3"
},
"top3": {
"label": "Top 3",
"field": "Top3",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top5": {
"label": "Top 5",
"field": "Top5",
"category": "Tops",
"valueInt": 20,
"value": "20",
"rank": 1438657,
"percentile": 15.0,
"displayValue": "20"
},
"top6": {
"label": "Top 6",
"field": "Top6",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top10": {
"label": "Top 10",
"field": "Top10",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top12": {
"label": "Top 12",
"field": "Top12",
"category": "Tops",
"valueInt": 56,
"value": "56",
"rank": 1335530,
"percentile": 14.0,
"displayValue": "56"
},
"top25": {
"label": "Top 25",
"field": "Top25",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"kd": {
"label": "K/d",
"field": "KD",
"category": "General",
"valueDec": 0.68,
"value": "0.68",
"rank": 2133720,
"percentile": 68.0,
"displayValue": "0.68"
},
"winRatio": {
"label": "Win %",
"field": "WinRatio",
"category": "General",
"valueDec": 0.9,
"value": "0.9",
"rank": 1752091,
"percentile": 55.0,
"displayValue": "0.90"
},
"matches": {
"label": "Matches",
"field": "Matches",
"category": "General",
"valueInt": 347,
"value": "347",
"rank": 944115,
"percentile": 30.0,
"displayValue": "347"
},
"kills": {
"label": "Kills",
"field": "Kills",
"category": "General",
"valueInt": 234,
"value": "234",
"rank": 1291960,
"percentile": 40.0,
"displayValue": "234"
},
"kpg": {
"label": "Kills Per Match",
"field": "KPG",
"category": "General",
"valueDec": 0.67,
"value": "0.67",
"rank": 2137868,
"percentile": 68.0,
"displayValue": "0.67"
},
"avgTimePlayed": {
"label": "Avg Match Time",
"field": "AvgTimePlayed",
"category": "General",
"valueDec": 273.72,
"value": "273.72",
"rank": 2125448,
"displayValue": "4m 33s"
},
"scorePerMatch": {
"label": "Score per Match",
"field": "ScorePerMatch",
"category": "General",
"valueDec": 134.77,
"value": "134.77",
"rank": 2058752,
"percentile": 63.0,
"displayValue": "134.77"
}
},
"p9": {
"trnRating": {
"label": "TRN Rating",
"field": "TRNRating",
"category": "Rating",
"valueInt": 1121,
"value": "1121",
"rank": 2180620,
"displayValue": "1,121"
},
"score": {
"label": "Score",
"field": "Score",
"category": "General",
"valueInt": 98339,
"value": "98339",
"rank": 880324,
"displayValue": "98,339"
},
"top1": {
"label": "Wins",
"field": "Top1",
"category": "Tops",
"valueInt": 8,
"value": "8",
"rank": 1488695,
"percentile": 31.0,
"displayValue": "8"
},
"top3": {
"label": "Top 3",
"field": "Top3",
"category": "Tops",
"valueInt": 36,
"value": "36",
"rank": 1240417,
"percentile": 13.0,
"displayValue": "36"
},
"top5": {
"label": "Top 5",
"field": "Top5",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top6": {
"label": "Top 6",
"field": "Top6",
"category": "Tops",
"valueInt": 80,
"value": "80",
"rank": 1113740,
"percentile": 11.0,
"displayValue": "80"
},
"top10": {
"label": "Top 10",
"field": "Top10",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top12": {
"label": "Top 12",
"field": "Top12",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top25": {
"label": "Top 25",
"field": "Top25",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"kd": {
"label": "K/d",
"field": "KD",
"category": "General",
"valueDec": 0.94,
"value": "0.94",
"rank": 1775409,
"percentile": 54.0,
"displayValue": "0.94"
},
"winRatio": {
"label": "Win %",
"field": "WinRatio",
"category": "General",
"valueDec": 1.3,
"value": "1.3",
"rank": 2230627,
"percentile": 49.0,
"displayValue": "1.30"
},
"matches": {
"label": "Matches",
"field": "Matches",
"category": "General",
"valueInt": 603,
"value": "603",
"rank": 677528,
"percentile": 14.0,
"displayValue": "603"
},
"kills": {
"label": "Kills",
"field": "Kills",
"category": "General",
"valueInt": 562,
"value": "562",
"rank": 873151,
"percentile": 21.0,
"displayValue": "562"
},
"kpg": {
"label": "Kills Per Match",
"field": "KPG",
"category": "General",
"valueDec": 0.93,
"value": "0.93",
"rank": 1731964,
"percentile": 53.0,
"displayValue": "0.93"
},
"avgTimePlayed": {
"label": "Avg Match Time",
"field": "AvgTimePlayed",
"category": "General",
"valueDec": 221.59,
"value": "221.59",
"rank": 2532805,
"displayValue": "3m 41s"
},
"scorePerMatch": {
"label": "Score per Match",
"field": "ScorePerMatch",
"category": "General",
"valueDec": 163.08,
"value": "163.08",
"rank": 2029616,
"percentile": 42.0,
"displayValue": "163.08"
}
},
"curr_p2": {
"trnRating": {
"label": "TRN Rating",
"field": "TRNRating",
"category": "Rating",
"valueInt": 1111,
"value": "1111",
"displayValue": "1,111"
},
"score": {
"label": "Score",
"field": "Score",
"category": "General",
"valueInt": 22500,
"value": "22500",
"rank": 470532,
"percentile": 26.0,
"displayValue": "22,500"
},
"top1": {
"label": "Wins",
"field": "Top1",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1238303,
"displayValue": "0"
},
"top3": {
"label": "Top 3",
"field": "Top3",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top5": {
"label": "Top 5",
"field": "Top5",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top6": {
"label": "Top 6",
"field": "Top6",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top10": {
"label": "Top 10",
"field": "Top10",
"category": "Tops",
"valueInt": 16,
"value": "16",
"rank": 526184,
"percentile": 6.0,
"displayValue": "16"
},
"top12": {
"label": "Top 12",
"field": "Top12",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top25": {
"label": "Top 25",
"field": "Top25",
"category": "Tops",
"valueInt": 43,
"value": "43",
"rank": 384684,
"percentile": 3.9,
"displayValue": "43"
},
"kd": {
"label": "K/d",
"field": "KD",
"category": "General",
"valueDec": 1.03,
"value": "1.03",
"rank": 1459203,
"displayValue": "1.03"
},
"matches": {
"label": "Matches",
"field": "Matches",
"category": "General",
"valueInt": 149,
"value": "149",
"rank": 455652,
"percentile": 19.0,
"displayValue": "149"
},
"kills": {
"label": "Kills",
"field": "Kills",
"category": "General",
"valueInt": 153,
"value": "153",
"rank": 637148,
"percentile": 26.0,
"displayValue": "153"
},
"kpg": {
"label": "Kills Per Match",
"field": "KPG",
"category": "General",
"valueDec": 1.03,
"value": "1.03",
"rank": 1446183,
"percentile": 51.0,
"displayValue": "1.03"
},
"avgTimePlayed": {
"label": "Avg Match Time",
"field": "AvgTimePlayed",
"category": "General",
"valueDec": 70.87,
"value": "70.87",
"rank": 962042,
"percentile": 39.0,
"displayValue": "1m 10s"
},
"scorePerMatch": {
"label": "Score per Match",
"field": "ScorePerMatch",
"category": "General",
"valueDec": 151.01,
"value": "151.01",
"rank": 1366860,
"percentile": 65.0,
"displayValue": "151.01"
}
},
"curr_p10": {
"trnRating": {
"label": "TRN Rating",
"field": "TRNRating",
"category": "Rating",
"valueInt": 1200,
"value": "1200",
"displayValue": "1,200"
},
"score": {
"label": "Score",
"field": "Score",
"category": "General",
"valueInt": 13669,
"value": "13669",
"rank": 1152025,
"percentile": 42.0,
"displayValue": "13,669"
},
"top1": {
"label": "Wins",
"field": "Top1",
"category": "Tops",
"valueInt": 1,
"value": "1",
"rank": 1151758,
"displayValue": "1"
},
"top3": {
"label": "Top 3",
"field": "Top3",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top5": {
"label": "Top 5",
"field": "Top5",
"category": "Tops",
"valueInt": 7,
"value": "7",
"rank": 1141708,
"percentile": 15.0,
"displayValue": "7"
},
"top6": {
"label": "Top 6",
"field": "Top6",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top10": {
"label": "Top 10",
"field": "Top10",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top12": {
"label": "Top 12",
"field": "Top12",
"category": "Tops",
"valueInt": 22,
"value": "22",
"rank": 903205,
"percentile": 11.0,
"displayValue": "22"
},
"top25": {
"label": "Top 25",
"field": "Top25",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"kd": {
"label": "K/d",
"field": "KD",
"category": "General",
"valueDec": 0.75,
"value": "0.75",
"rank": 1887251,
"displayValue": "0.75"
},
"winRatio": {
"label": "Win %",
"field": "WinRatio",
"category": "General",
"valueDec": 1.0,
"value": "1",
"rank": 1443516,
"percentile": 54.0,
"displayValue": "1.00"
},
"matches": {
"label": "Matches",
"field": "Matches",
"category": "General",
"valueInt": 96,
"value": "96",
"rank": 936423,
"percentile": 35.0,
"displayValue": "96"
},
"kills": {
"label": "Kills",
"field": "Kills",
"category": "General",
"valueInt": 71,
"value": "71",
"rank": 1252315,
"percentile": 46.0,
"displayValue": "71"
},
"kpg": {
"label": "Kills Per Match",
"field": "KPG",
"category": "General",
"valueDec": 0.74,
"value": "0.74",
"rank": 1893112,
"percentile": 71.0,
"displayValue": "0.74"
},
"avgTimePlayed": {
"label": "Avg Match Time",
"field": "AvgTimePlayed",
"category": "General",
"valueDec": 26.88,
"value": "26.88",
"rank": 2497616,
"percentile": 91.0,
"displayValue": "26s"
},
"scorePerMatch": {
"label": "Score per Match",
"field": "ScorePerMatch",
"category": "General",
"valueDec": 142.39,
"value": "142.39",
"rank": 1954451,
"percentile": 71.0,
"displayValue": "142.39"
}
},
"curr_p9": {
"trnRating": {
"label": "TRN Rating",
"field": "TRNRating",
"category": "Rating",
"valueInt": 1121,
"value": "1121",
"displayValue": "1,121"
},
"score": {
"label": "Score",
"field": "Score",
"category": "General",
"valueInt": 48923,
"value": "48923",
"rank": 498058,
"percentile": 8.0,
"displayValue": "48,923"
},
"top1": {
"label": "Wins",
"field": "Top1",
"category": "Tops",
"valueInt": 4,
"value": "4",
"rank": 1164590,
"displayValue": "4"
},
"top3": {
"label": "Top 3",
"field": "Top3",
"category": "Tops",
"valueInt": 16,
"value": "16",
"rank": 861117,
"percentile": 11.0,
"displayValue": "16"
},
"top5": {
"label": "Top 5",
"field": "Top5",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top6": {
"label": "Top 6",
"field": "Top6",
"category": "Tops",
"valueInt": 38,
"value": "38",
"rank": 634089,
"percentile": 7.0,
"displayValue": "38"
},
"top10": {
"label": "Top 10",
"field": "Top10",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top12": {
"label": "Top 12",
"field": "Top12",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"top25": {
"label": "Top 25",
"field": "Top25",
"category": "Tops",
"valueInt": 0,
"value": "0",
"rank": 1,
"displayValue": "0"
},
"kd": {
"label": "K/d",
"field": "KD",
"category": "General",
"valueDec": 1.02,
"value": "1.02",
"rank": 1482777,
"displayValue": "1.02"
},
"winRatio": {
"label": "Win %",
"field": "WinRatio",
"category": "General",
"valueDec": 1.2,
"value": "1.2",
"rank": 1953805,
"percentile": 52.0,
"displayValue": "1.20"
},
"matches": {
"label": "Matches",
"field": "Matches",
"category": "General",
"valueInt": 322,
"value": "322",
"rank": 188452,
"percentile": 2.8,
"displayValue": "322"
},
"kills": {
"label": "Kills",
"field": "Kills",
"category": "General",
"valueInt": 324,
"value": "324",
"rank": 455442,
"percentile": 10.0,
"displayValue": "324"
},
"kpg": {
"label": "Kills Per Match",
"field": "KPG",
"category": "General",
"valueDec": 1.01,
"value": "1.01",
"rank": 1435682,
"percentile": 52.0,
"displayValue": "1.01"
},
"avgTimePlayed": {
"label": "Avg Match Time",
"field": "AvgTimePlayed",
"category": "General",
"valueDec": 27.02,
"value": "27.02",
"rank": 2559533,
"percentile": 91.0,
"displayValue": "27s"
},
"scorePerMatch": {
"label": "Score per Match",
"field": "ScorePerMatch",
"category": "General",
"valueDec": 151.93,
"value": "151.93",
"rank": 2317854,
"percentile": 64.0,
"displayValue": "151.93"
}
}
},
"lifeTimeStats": [
{
"key": "Top 3",
"value": "56"
},
{
"key": "Top 5s",
"value": "20"
},
{
"key": "Top 3s",
"value": "36"
},
{
"key": "Top 6s",
"value": "80"
},
{
"key": "Top 12s",
"value": "56"
},
{
"key": "Top 25s",
"value": "176"
},
{
"key": "Score",
"value": "242,636"
},
{
"key": "Matches Played",
"value": "1608"
},
{
"key": "Wins",
"value": "14"
},
{
"key": "Win%",
"value": "1%"
},
{
"key": "Kills",
"value": "1476"
},
{
"key": "K/d",
"value": "0.93"
},
{
"key": "Kills Per Min",
"value": "0.2"
},
{
"key": "Time Played",
"value": "5d 2h 37m "
},
{
"key": "Avg Survival Time",
"value": "4m 34s"
}
],
"recentMatches": [
{
"id": 71608051,
"accountId": "649eb4a8-584e-4896-adc9-66569ee92139",
"playlist": "p2",
"kills": 15,
"minutesPlayed": 0,
"top1": 0,
"top5": 0,
"top6": 0,
"top10": 2,
"top12": 0,
"top25": 4,
"matches": 16,
"top3": 0,
"dateCollected": "2018-03-21T12:26:33.713",
"score": 2018,
"platform": 3,
"trnRating": 1111.8,
"trnRatingChange": -9.6963567258982941
},
{
"id": 71608050,
"accountId": "649eb4a8-584e-4896-adc9-66569ee92139",
"playlist": "p9",
"kills": 7,
"minutesPlayed": 0,
"top1": 0,
"top5": 0,
"top6": 2,
"top10": 0,
"top12": 0,
"top25": 0,
"matches": 11,
"top3": 0,
"dateCollected": "2018-03-21T12:26:33.697",
"score": 1342,
"platform": 3,
"trnRating": 1121.4,
"trnRatingChange": -9.6722971885223643
},
...
You can use the built-in .json() function of the requests module.
headers = {'TRN-Api-Key': '52f2fbde-018d-47b5-9c7d-99990c0d3507'}
url = 'https://api.fortnitetracker.com/v1/profile/pc/loopisjones'
r = requests.get(url, headers=headers)
data = r.json()
for item in data['lifeTimeStats']:
if item['key'] == 'Kills':
print(item['value'])
Output:
1520