eoLinker-API_Shop_炉石传说卡牌查询_API接口_Python调用示例代码

上传人:亿*** 文档编号:42563865 上传时间:2018-06-02 格式:DOCX 页数:5 大小:11.38KB
返回 下载 相关 举报
eoLinker-API_Shop_炉石传说卡牌查询_API接口_Python调用示例代码_第1页
第1页 / 共5页
eoLinker-API_Shop_炉石传说卡牌查询_API接口_Python调用示例代码_第2页
第2页 / 共5页
eoLinker-API_Shop_炉石传说卡牌查询_API接口_Python调用示例代码_第3页
第3页 / 共5页
eoLinker-API_Shop_炉石传说卡牌查询_API接口_Python调用示例代码_第4页
第4页 / 共5页
eoLinker-API_Shop_炉石传说卡牌查询_API接口_Python调用示例代码_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

《eoLinker-API_Shop_炉石传说卡牌查询_API接口_Python调用示例代码》由会员分享,可在线阅读,更多相关《eoLinker-API_Shop_炉石传说卡牌查询_API接口_Python调用示例代码(5页珍藏版)》请在金锄头文库上搜索。

1、eoLinker-API Shop 炉石炉石传说传说卡牌卡牌查询查询 Python调调用示例代用示例代码码炉石炉石传说传说卡牌卡牌查询查询获取炉石传说卡牌信息,可获取全部,也可根据关键字查询某卡牌。该产该产品品拥拥有以下有以下APIs: :1.关键字获取卡牌列表2.获取卡牌列表3.获取卡牌信息注意,注意,该该示例代示例代码仅码仅适用于适用于 网站下网站下API 使用使用该产该产品前,您需要通品前,您需要通过过 https:/ 申申请请API服服务务1.关关键键字字获获取卡牌列表取卡牌列表 #!/usr/bin/env python # -*- coding: utf-8 -*- # 测试环境

2、: python2.7 # 安装requests依赖 = pip install requests/ easy_install requests# 导入requests依赖 import requests import json import sysreload(sys) sys.setdefaultencoding(utf-8)def apishop_send_request(method, url, params=None, headers=None):转发请求到目的主机param method str 请求方法param url str 请求地址param params dict 请求参

3、数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 Nonemethod = “POST“ url = “https:/ headers = None params = “apiKey“:“your_api_key“, #

4、需要从获取 “keyword“:“ #关键字 “page“:“ #当前页码(默认1) “pageSize“:“ #当前页面卡牌数量(默认30) result = apishop_send_request(method=method, url=url, params=params, headers=headers) if result:body = result.textresponse = json.loads(body)status_code = response“statusCode“if (status_code = 000000):# 状态码为000000, 说明请求成功print(请

5、求成功:%s % (body,)else:# 状态码非000000, 说明请求失败print(请求失败: %s % (body,) else:# 返回内容异常,发送请求失败print(发送请求失败)2.获获取卡牌列表取卡牌列表 #!/usr/bin/env python # -*- coding: utf-8 -*- # 测试环境: python2.7 # 安装requests依赖 = pip install requests/ easy_install requests# 导入requests依赖 import requests import json import sysreload(sy

6、s) sys.setdefaultencoding(utf-8)def apishop_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 meth

7、od = GET:return requests.get(url=url, params=params, headers=headers)else:return Nonemethod = “POST“ url = “https:/ headers = None params = “apiKey“:“your_api_key“, #需要从获取 “page“:“ #当前页码(默认1) “pageSize“:“ #当前页面卡牌数量(默认30) result = apishop_send_request(method=method, url=url, params=params, headers=he

8、aders) if result:body = result.textresponse = json.loads(body)status_code = response“statusCode“if (status_code = 000000):# 状态码为000000, 说明请求成功print(请求成功:%s % (body,)else:# 状态码非000000, 说明请求失败print(请求失败: %s % (body,) else:# 返回内容异常,发送请求失败print(发送请求失败)3.获获取卡牌信息取卡牌信息 #!/usr/bin/env python # -*- coding: u

9、tf-8 -*- # 测试环境: python2.7 # 安装requests依赖 = pip install requests/ easy_install requests# 导入requests依赖 import requests import json import sysreload(sys) sys.setdefaultencoding(utf-8)def apishop_send_request(method, url, params=None, headers=None):转发请求到目的主机param method str 请求方法param url str 请求地址param

10、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 Nonemethod = “POST“ url = “https:/ headers = None params = “apiKey“:“y

11、our_api_key“, #需要从获取 “cardID“:“ #卡牌ID result = apishop_send_request(method=method, url=url, params=params, headers=headers) if result:body = result.textresponse = json.loads(body)status_code = response“statusCode“if (status_code = 000000):# 状态码为000000, 说明请求成功print(请求成功:%s % (body,)else:# 状态码非000000, 说明请求失败print(请求失败: %s % (body,) else:# 返回内容异常,发送请求失败print(发送请求失败)

展开阅读全文
相关资源
相关搜索

当前位置:首页 > IT计算机/网络 > 开发文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号