python 工行 api 查询
2011-03-24 16:33
211 查看
最近学习python 又在做接口 于是找了N多资料 终于实现了 下面是代码
# -*- coding:gbk -*-
import httplib
import cookielib
import urllib2
import urllib
# 用chilkat拆分pfx得到key,cert的pem格式
key_file = 'chilkat_pkey.pem'
cert_file = 'chilkat_cert.pem'
class HTTPSClientAuthConnection(httplib.HTTPSConnection):
def __init__(self, host, timeout=None):
httplib.HTTPSConnection.__init__(self, host, key_file=key_file,cert_file=cert_file)
self.timeout = timeout # Only valid in Python 2.6
class HTTPSClientAuthHandler(urllib2.HTTPSHandler):
def https_open(self, req):
return self.do_open(HTTPSClientAuthConnection, req)
class ICBCAPI(object):
def __init__(self):
self._cookiejar = cookielib.CookieJar()
def get(self, url, **data):
parameters = urllib.urlencode(data)
opener = urllib2.build_opener(urllib2.HTTPHandler(), HTTPSClientAuthHandler(), urllib2.HTTPCookieProcessor(self._cookiejar))
req = urllib2.Request(url, parameters)
server_response = opener.open(req).read()
return urllib2.unquote(server_response)
def test():
api = ICBCAPI()
apiUrl = "https://corporbank3.dccnet.com.cn/servlet/ICBCINBSEBusinessServlet"
merReqData = '''
<?xml version="1.0" encoding="GBK\" standalone="no" ?>
<ICBCAPI>
<in>
<orderNum>填你们自己的</orderNum>
<tranDate>填你们自己的</tranDate>
<ShopCode>填你们自己的</ShopCode>
<ShopAccount>填你们自己的</ShopAccount>
</in>
</ICBCAPI>'''
print api.get(apiUrl,APIName='EAPI',APIVersion='001.001.002.001',MerReqData=merReqData)
if __name__ == '__main__':
test()
希望对你们有帮助
# -*- coding:gbk -*-
import httplib
import cookielib
import urllib2
import urllib
# 用chilkat拆分pfx得到key,cert的pem格式
key_file = 'chilkat_pkey.pem'
cert_file = 'chilkat_cert.pem'
class HTTPSClientAuthConnection(httplib.HTTPSConnection):
def __init__(self, host, timeout=None):
httplib.HTTPSConnection.__init__(self, host, key_file=key_file,cert_file=cert_file)
self.timeout = timeout # Only valid in Python 2.6
class HTTPSClientAuthHandler(urllib2.HTTPSHandler):
def https_open(self, req):
return self.do_open(HTTPSClientAuthConnection, req)
class ICBCAPI(object):
def __init__(self):
self._cookiejar = cookielib.CookieJar()
def get(self, url, **data):
parameters = urllib.urlencode(data)
opener = urllib2.build_opener(urllib2.HTTPHandler(), HTTPSClientAuthHandler(), urllib2.HTTPCookieProcessor(self._cookiejar))
req = urllib2.Request(url, parameters)
server_response = opener.open(req).read()
return urllib2.unquote(server_response)
def test():
api = ICBCAPI()
apiUrl = "https://corporbank3.dccnet.com.cn/servlet/ICBCINBSEBusinessServlet"
merReqData = '''
<?xml version="1.0" encoding="GBK\" standalone="no" ?>
<ICBCAPI>
<in>
<orderNum>填你们自己的</orderNum>
<tranDate>填你们自己的</tranDate>
<ShopCode>填你们自己的</ShopCode>
<ShopAccount>填你们自己的</ShopAccount>
</in>
</ICBCAPI>'''
print api.get(apiUrl,APIName='EAPI',APIVersion='001.001.002.001',MerReqData=merReqData)
if __name__ == '__main__':
test()
希望对你们有帮助
相关文章推荐
- 利用Python的Django框架中的ORM建立查询API
- Python Elasticsearch api,组合过滤器,term过滤器,正则查询 ,match查询,获取最近一小时的数据
- Python Elasticsearch api,组合过滤器,term过滤器,正则查询 ,match查询,获取最近一小时的数据
- python3.6 通过调用 阿里云 API (非SDK方式) 16ca 查询 可用区 例子
- Atitit. 注册表操作查询 修改 api与工具总结 java c# php js python 病毒木马的原理
- python火车余票查询(stationapi)
- Python调用百度API之天气查询
- python使用在线API查询IP对应的地理位置信息实例
- Atitit. 注册表操作查询 修改 api与工具总结 java c# php js python 病毒木马的原理
- python学习(一)---基础知识(安装、IDE、API查询、常见问题)
- Atitit. 注册表操作查询 修改 api与工具总结 java c# php js python 病毒木马的原理
- python使用在线API查询IP对应的地理位置信息实例
- sphinx python api 误用导致查询不到
- Python使用淘宝API查询IP归属地功能分享
- BAE+Python+Django+Wechatpy+Baidu weather api +微信订阅号 = 实现微信查询天气
- 工行支付api查询asp.net C# 实现
- 50万邮件文本分域检索与查询的python实现(3)
- 对python调用微软API代码的理解
- appium-python api