Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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
List 如何在Python中使用API键执行API请求_List_Api_Dictionary_Key_Screen Scraping - Fatal编程技术网

List 如何在Python中使用API键执行API请求

List 如何在Python中使用API键执行API请求,list,api,dictionary,key,screen-scraping,List,Api,Dictionary,Key,Screen Scraping,所以我一直在尝试访问这个API,但我需要使用API密钥来访问它。我有一个API密钥,但我不确定如何格式化所有内容并传输url。我的url看起来像这样-- 我使用的sit也会留下以下信息: This is the documentation for SportsDataIO's NFL API. All of our API endpoints can be accessed via an HTTP GET request using your API key. The API key can b

所以我一直在尝试访问这个API,但我需要使用API密钥来访问它。我有一个API密钥,但我不确定如何格式化所有内容并传输url。我的url看起来像这样--

我使用的sit也会留下以下信息:

This is the documentation for SportsDataIO's NFL API. All of our API endpoints can be accessed via an HTTP GET request using your API key. The API key can be passed either as a query parameter or using the following HTTP request header.
Ocp-Apim-Subscription-Key: {key}
我不知道这意味着什么,我对数据抓取是相当陌生的


如果有人能提供帮助,那就太好了,谢谢。

意味着您需要通过标题传递api密钥:

import requests

api_key = 'put your api key here'

url = 'https://api.sportsdata.io/v3/nfl/scores/json/Players'
headers = {'Ocp-Apim-Subscription-Key': '{key}'.format(key=api_key)}

jsonData = requests.get(url, headers=headers).json()

你在用python吗?是的,我在用python