我正在从http://www.nfib-sbet.org/developers/中提取数据。我无法在网站上复制该演示
示例API请求:
方法:开机自检 响应内容类型:application / json 参数内容类型:application / json 网址:
http://open.api.nfib-sbet.org/rest/sbetdb/_proc/getIndicators
请求正文:
{
"app_name": "sbet",
"params": [
{ "name": "minYear", "param_type": "IN", "value": 2010 },
{ "name": "minMonth", "param_type": "IN", "value": 6 },
{ "name": "maxYear", "param_type": "IN", "value": 2010 },
{ "name": "maxMonth", "param_type": "IN", "value": 12 },
{ "name": "indicator", "param_type": "IN", "value": "OPT_INDEX" }
]
}
所以我想出了这段代码来提取数据:
import pandas as pd
import time
import requests
import urllib
import json
import re
import datetime
import os
import sys
import glob
import json
params = {
"app_name": "sbet"}
data = {
"minYear": 2010 ,
"minMonth": 6 ,
"maxYear": 2010 ,
"maxMonth": 12 ,
"indicator": "OPT_INDEX"
}
headers = {'Content-type': 'application/json'}
This_URL = "http://open.api.nfib-sbet.org/rest/sbetdb/_proc/getIndicators"
# Make a get request with the parameters.
requests.post(url=This_URL, params=params, data=json.dumps(data),headers = headers)
但是它不断返回
<Response [500]>