我一直在使用nflgame和nfldb模块从nfl xml数据中提取日程表,但是我注意到使用以下函数生成的URL返回404错误。最近有没有其他人经历过这种情况,并且知道为什么会这样?
def schedule_url(year, stype, week):
"""
Returns the NFL.com XML schedule URL. `year` should be an
integer, `stype` should be one of the strings `PRE`, `REG` or
`POST`, and `gsis_week` should be a value in the range
`[0, 17]`.
"""
xmlurl = 'http://www.nfl.com/ajax/scorestrip?'
if stype == 'POST':
week += 17
if week == 21: # NFL.com you so silly
week += 1
return '%sseason=%d&seasonType=%s&week=%d' % (xmlurl, year, stype, week)
schedule_url(2019, 'REG', 1)
答案 0 :(得分:2)
nfl.com重组了其站点和API。 nflgame严重依赖于此,现在不再起作用。您将需要找到一种替代方法来获取nfl日程安排,实时比分,更新,逐场比赛等。
您可以从ESPN endpoints
获取时间表import requests
headers = {'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Mobile Safari/537.36'}
url = "http://site.api.espn.com/apis/site/v2/sports/football/nfl/scoreboard"
payload = {'week':'1'}
jsonData = requests.get(url, headers=headers, params=payload).json()
答案 1 :(得分:1)
这是我用来获取分数的方式,因为旧的不再起作用。
https://static.nfl.com/liveupdate/scorestrip/ss.xml
使用“ https://static.nfl.com/ajax/scorestrip?”或只将www部分替换为static部分,就可以了。
答案 2 :(得分:0)
此外,对于以后的游戏,新的网站格式为:
https://static.nfl.com/ajax/scorestrip?season=2020&seasonType=REG&week=2