จะหาข้อมูลกำหนดการ NFL XML สำหรับปี 2020 ได้ที่ไหน

Aug 16 2020

ฉันดึงตารางเวลาจากข้อมูล nfl xml โดยใช้โมดูล nflgame และ nfldb แต่ฉันสังเกตเห็นว่า 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)

คำตอบ

2 chitown88 Aug 17 2020 at 07:31

nfl.com ปรับโครงสร้างเว็บไซต์และ API ใหม่ nflgame อาศัยสิ่งนั้นอย่างมากซึ่งตอนนี้ใช้งานไม่ได้อีกต่อไป คุณจะต้องหาทางเลือกอื่นในการรับตาราง nfl คะแนนสดการอัปเดตการเล่นโดยการเล่น ฯลฯ

คุณสามารถรับกำหนดการได้จากปลายทาง ESPN

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 Amor Sep 04 2020 at 00:02

นี่คือสิ่งที่ฉันใช้ในการรับคะแนนเนื่องจากอันเก่าใช้ไม่ได้อีกต่อไป

https://static.nfl.com/liveupdate/scorestrip/ss.xml

ใช้ 'https://static.nfl.com/ajax/scorestrip?' หรือเพียงแค่แทนที่ส่วน www เป็นแบบคงที่และคุณก็พร้อมใช้งาน

rswayz Sep 15 2020 at 12:27

นอกจากนี้สำหรับเกมในอนาคตรูปแบบไซต์ใหม่คือ:

https://static.nfl.com/ajax/scorestrip?season=2020&seasonType=REG&week=2