本代码示例是基于Python的六派数据接口进行数据请求 API服务请求的代码示例,使用前你需要:
①:通过https://www.6api.net/api/enterprise2/ 申请API服务
以下是完整代码示例:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 测试环境: python2.7
# 安装requests依赖 => pip install requests/ easy_install requests
import requests
import json
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
def api_send_request(method, url, params=None, headers=None):
'''
转发请求到目的主机
@param method str 请求方法
@param url str 请求地址
@param params dict 请求参数
@param headers dict 请求头
'''
method = str.upper(method)
if method == "POST":
return requests.post(url=url, data=params, headers=headers)
elif method == "GET":
return requests.get(url=url, params=params, headers=headers)
else:
return None
method = "POST"
url = "http://open.liupai.net/enterprise2/query"
headers = None
params = {
"appkey" : "yourappsecret",
"company" : "参数1",
"creditno" : "参数2",
"regno" : "参数3"
}
result = api_send_request(method=method, url=url, params=params, headers=headers)
if result:
body = result.result
response = json.loads(body)
status_code = response["status"]
if (sta
本代码示例是基于Python的六派数据接口进行数据请求 API服务请求的代码示例,使用前你需要:
①:通过https://www.6api.net/api/enterprise2/ 申请API服务
以下是完整代码示例:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 测试环境: python2.7
# 安装requests依赖 => pip install requests/ easy_install requests
import requests
import json
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
def api_send_request(method, url, params=None, headers=None):
'''
转发请求到目的主机
@param method str 请求方法
@param url str 请求地址
@param params dict 请求参数
@param headers dict 请求头
'''
method = str.upper(method)
if method == "POST":
return requests.post(url=url, data=params, headers=headers)
elif method == "GET":
return requests.get(url=url, params=params, headers=headers)
else:
return None
method = "POST"
url = "http://open.liupai.net/enterprise2/search"
headers = None
params = {
"appkey" : "yourappsecret",
"keyword" : "参数1"
}
result = api_send_request(method=method, url=url, params=params, headers=headers)
if result:
body = result.result
response = json.loads(body)
status_code = response["status"]
if (status_code == "200"):
print("请求成功:%s" % (body,))
el
本代码示例是基于Python的六派数据接口进行数据请求 API服务请求的代码示例,使用前你需要:
①:通过https://www.6api.net/api/enterprise2/ 申请API服务
以下是完整代码示例:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 测试环境: python2.7
# 安装requests依赖 => pip install requests/ easy_install requests
import requests
import json
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
def api_send_request(method, url, params=None, headers=None):
'''
转发请求到目的主机
@param method str 请求方法
@param url str 请求地址
@param params dict 请求参数
@param headers dict 请求头
'''
method = str.upper(method)
if method == "POST":
return requests.post(url=url, data=params, headers=headers)
elif method == "GET":
return requests.get(url=url, params=params, headers=headers)
else:
return None
method = "POST"
url = "http://open.liupai.net/enterprise2/zzzstotal"
headers = None
params = {
"appkey" : "yourappsecret",
"keyword" : "参数1"
}
result = api_send_request(method=method, url=url, params=params, headers=headers)
if result:
body = result.result
response = json.loads(body)
status_code = response["status"]
if (status_code == "200"):
print("请求成功:%s" % (body,))
else:
print("请求失败: %s" % (body,))
else:
print("发送请求失败")