使用 python(不记名令牌)抓取 fanteam.com
scraping fanteam.com with python (Bearer token)
我正在尝试收集 fanteam.com 上个人玩家获得的幻想点数。例如本次锦标赛:https://www.fanteam.com/fantasy/dashboard/439470/8955379/3
我想知道哪个玩家获得了多少分。由于在找到所有球员之前单击所有球队非常乏味,因此我正在编写 python 脚本。通过网络分析,我发现数据在https://fanteam-game.api.scoutgg.net/fantasy_teams/8955379?round=3(也许有更好的来源):
很遗憾,您需要持有者令牌才能访问此 link。我尝试了来自互联网的不同手册,但到目前为止没有任何效果。如何获取令牌?
尝试:
import json
import requests
url = "https://fanteam-game.api.scoutgg.net/fantasy_teams/8955379?round=3"
headers = {"Authorization": "Bearer fanteam undefined"}
data = requests.get(url, headers=headers).json()
# uncomment this to print all data:
# print(json.dumps(data, indent=4))
for p in data["playerChoices"]:
print(
p["realPlayer"]["firstName"], p["realPlayer"]["lastName"], p["points"]
)
打印:
Matteo Berrettini 56.78
Hubert Hurkacz 58.28
Felix Auger-Aliassime 50.13
Ashleigh Barty 52.3
Karolina Muchova 54.25
Barbora Krejcikova 30.3
我正在尝试收集 fanteam.com 上个人玩家获得的幻想点数。例如本次锦标赛:https://www.fanteam.com/fantasy/dashboard/439470/8955379/3 我想知道哪个玩家获得了多少分。由于在找到所有球员之前单击所有球队非常乏味,因此我正在编写 python 脚本。通过网络分析,我发现数据在https://fanteam-game.api.scoutgg.net/fantasy_teams/8955379?round=3(也许有更好的来源):
很遗憾,您需要持有者令牌才能访问此 link。我尝试了来自互联网的不同手册,但到目前为止没有任何效果。如何获取令牌?
尝试:
import json
import requests
url = "https://fanteam-game.api.scoutgg.net/fantasy_teams/8955379?round=3"
headers = {"Authorization": "Bearer fanteam undefined"}
data = requests.get(url, headers=headers).json()
# uncomment this to print all data:
# print(json.dumps(data, indent=4))
for p in data["playerChoices"]:
print(
p["realPlayer"]["firstName"], p["realPlayer"]["lastName"], p["points"]
)
打印:
Matteo Berrettini 56.78
Hubert Hurkacz 58.28
Felix Auger-Aliassime 50.13
Ashleigh Barty 52.3
Karolina Muchova 54.25
Barbora Krejcikova 30.3