#-*-coding:utf-8-*- import time import uuid import jpype import requests def test2(): reqURL = 'https://sfapi.sf-express.com/std/service' #reqURL = 'http://bspoisp.sit.sf-express.com:11080/bsp-oisp/sfexpressService' clientCode = 'YYWLKJ_gW9f7' #checkword = 'TXPFK2TC361Q' checkword = 'qFjwDNSazZo7M4iWccCOYErWUZNkf765' # msgData={"checkNos":[""],"checkType":1,"searchNo":"SF1011800272101"} msgData = '{"checkNos":["400-6151818"],"checkType":1,"searchNo":"SF1096043382492"}' #msgData= 'test' print(msgData) headers = { "Content-type": "application/x-www-form-urlencoded;charset=UTF-8", 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1', } timestamp = int(time.time() * 10000) timestamp='1597841986762' jpype.startJVM( jpype.getDefaultJVMPath(), '-ea', '-Djava.class.path=/data/java/MD5DigestUtil.jar', ) javaClass = jpype.JClass('com.sf.MD5DigestUtil') javaInstance = javaClass() msgDigest = javaInstance.digest(msgData, str(timestamp), checkword) print('msgData, timestamp, checkword:',msgData, str(timestamp), checkword) #print('msgDigest:','aaa'+str(msgDigest)) #msgDigest='OmrLn1zNLiWNsAC5/e36WQ==' data = { 'partnerID': clientCode, # 'requestID':str(uuid.uuid4()).replace('-', ''), 'requestID': str(uuid.uuid4()), 'serviceCode': 'EXP_RECE_SEARCH_PROMITM', 'timestamp': timestamp, 'msgData': msgData, 'msgDigest': str(msgDigest), } print('请求地址:', reqURL) print('请求参数:', data) res = requests.post(url=reqURL, data=data, headers=headers) # print('request.headers:',res.request.headers) # print('response_status_code:',res.status_code) print('返回值:', res.text) if __name__ == '__main__': test2()
需在linux 上, jar 在baidupan