【问题标题】:404 page not found when requesting JSON from The Rundown API从 The Rundown API 请求 JSON 时找不到 404 页面
【发布时间】:2020-10-07 17:27:43
【问题描述】:

感谢您的光临。当我对 The Rundown API 执行获取请求时,我收到“404 page not found”消息。我已经浏览了docs,并且我相信我使用的是适当的 URL。 我专门寻找体育赛事,我使用了这两个网址:

https://therundown-therundown-v1.p.rapidapi.com/sports/1/events?include=scores //应该返回预计分数

https://therundown-therundown-v1.p.rapidapi.com/sports/1/events //应该返回这项运动即将举行的所有活动

我的 API 密钥正在工作,我确实从其他 URL 获取数据,即

https://therundown-therundown-v1.p.rapidapi.com/sports/1/events/6-1-2019//返回当天体育赛事的数据

这是我的代码:

url = "https://therundown-therundown-v1.p.rapidapi.com/sports/1/events"

headers = {
    'x-rapidapi-host': "therundown-therundown-v1.p.rapidapi.com",
    'x-rapidapi-key': "{my_api_key}"
}

response = requests.request("GET", url, headers=headers)

print(response.text)

我想知道我是否没有获得任何数据,因为可能许多运动的时间表由于大流行而搞砸了......但我想我只会得到一个空的对象,而不是一个404。 任何帮助将不胜感激。再次感谢!

【问题讨论】:

    标签: json python-3.x api


    【解决方案1】:

    问题是他们在上面链接中的文档已经过时了。显然,上述端点不再起作用。 Here 是他们新文档的链接。 现在,如果您想获取特定运动的所有未来事件,您可以执行以下操作

    url = "https://therundown-therundown-v1.p.rapidapi.com/sports/1/dates"
    
    headers = {
        'x-rapidapi-host': "therundown-therundown-v1.p.rapidapi.com",
        'x-rapidapi-key': "a305c330demsh7dded55db30fb5cp17605fjsnda27dcdd58f3"
    }
    
    res = requests.request("GET", url, headers=headers)
    
    dates = res.text
    dates = json.loads(dates)
    dates_list = dates["dates"]
    for date in dates_list:
        event_url = "https://therundown-therundown-v1.p.rapidapi.com/sports/1/events/" + date
        event_res = requests.request("GET", event_url, headers=headers)
        print(event_res.text)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-30
      • 2018-04-18
      • 2019-08-01
      • 2020-08-15
      • 2023-03-22
      • 2018-07-13
      • 2021-07-25
      相关资源
      最近更新 更多