• python 调用jar


    #-*-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

  • 相关阅读:
    SVN中的Trunk、Tag、Brance的用法
    开发下载地址汇集
    Hessian原理分析
    Java中间件:淘宝网系统高性能利器
    linux进阶
    常见的Hadoop十大应用误解
    搜索引擎汇总
    bat薪酬
    常用的快速Web原型图设计工具
    apache kafka消息服务
  • 原文地址:https://www.cnblogs.com/du-jun/p/13558615.html
Copyright © 2020-2023  润新知