Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 哪里可以找到2020年NFL XML时间表数据_Python_Xml - Fatal编程技术网

Python 哪里可以找到2020年NFL XML时间表数据

Python 哪里可以找到2020年NFL XML时间表数据,python,xml,Python,Xml,我一直在使用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

我一直在使用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)

nfl.com重组了他们的网站和API。nflgame在很大程度上依赖于这一点,而这一点现在已经不起作用了。你需要找到一个替代方案来获得nfl的时间表、现场得分、更新、逐场比赛等

不过,你可以从


这就是我用来获取分数的方法,因为旧的方法已经不起作用了


使用'https://static.nfl.com/ajax/scorestrip?'或者只需将www部分替换为静态,就可以了。

此外,对于未来的游戏,新的网站格式是:

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()