• 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

  • 相关阅读:
    正则表达式中匹配中文
    计算机中的颜色——颜色概述
    人物系列Claude Shannon
    reading listfrom other blog
    how to write Makefile
    《麻省理工大学开放课程:线性代数》[中英双语字幕]视频下载
    正则表达式30分钟入门教程
    usage of fscanf and other read functions in C/C++
    《麻省理工大学开放课程:线性代数》学习
    Open review of papers
  • 原文地址:https://www.cnblogs.com/du-jun/p/13558615.html
Copyright © 2020-2023  润新知