本代码示例是基于Python的六派数据接口进行数据请求 API服务请求的代码示例,使用前你需要:
①:通过https://www.6api.net/api/car/ 申请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.6api.net/car/brand"
headers = None
params = {
"appkey" : "yourappsecret"
}
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("发送请求失败")
本代码示例是基于Python的六派数据接口进行数据请求 API服务请求的代码示例,使用前你需要:
①:通过https://www.6api.net/api/car/ 申请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.6api.net/car/series"
headers = None
params = {
"appkey" : "yourappsecret",
"parentid" : "参数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("发送请求失败")
本代码示例是基于Python的六派数据接口进行数据请求 API服务请求的代码示例,使用前你需要:
①:通过https://www.6api.net/api/car/ 申请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/car/detail"
headers = None
params = {
"appkey" : "yourappsecret",
"carid" : "参数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("发送请求失败")
本代码示例是基于Python的六派数据接口进行数据请求 API服务请求的代码示例,使用前你需要:
①:通过https://www.6api.net/api/car/ 申请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 = "https://open.6api.net/car/type"
headers = None
params = {
"appkey" : "yourappsecret",
"parentid" : "33"
}
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("发送请求失败")
本代码示例是基于Python的六派数据接口进行数据请求 API服务请求的代码示例,使用前你需要:
①:通过https://www.6api.net/api/car/ 申请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 = "https://open.6api.net/car/manufacturer"
headers = None
params = {
"appkey" : "yourappsecret"
}
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("发送请求失败")
本代码示例是基于Python的六派数据接口进行数据请求 API服务请求的代码示例,使用前你需要:
①:通过https://www.6api.net/api/car/ 申请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 = "https://open.6api.net/car/car"
headers = None
params = {
"appkey" : "yourappsecret",
"parentid" : "4851"
}
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("发送请求失败")