コード例 #1
0
def comp_common(urlOn, urlTest, data, *args):
    request = Prpcrypt('d3YmI1BUOSE2S2YmalBVZUQ=', "0000000000000000").encrypt(json.dumps(data))
    print(request)
    responseOn = requests.post(urlOn, data={'request': request}, verify=False)
    responseTest = requests.post(urlTest, data={'request': request}, verify=False)
    onJ = responseOn.json()
    testJ = responseTest.json()
    del onJ['msg']
    del onJ['stamp']
    on = json.dumps(onJ, sort_keys=True, ensure_ascii=False, indent=4)
    del testJ['msg']
    del testJ['stamp']
    test = json.dumps(testJ, sort_keys=True, ensure_ascii=False, indent=4)
    diff = difflib.context_diff(on.splitlines(keepends=True), test.splitlines(keepends=True), '线上', '测试')
    print(urlOn, urlTest)
    print(''.join(diff), end="")
コード例 #2
0
def comp_result(urlOn, urlTest, file):
    with open(file, 'r', encoding='utf-8') as w:
        lines = w.readlines()
        for line in lines:
            regionId = line.split(',')[0]
            regionName = line.split(',')[1].split('\n')[0]
            data = {"header": {"appVersion": "4.0.2", "cmdId": 0, "platformVersion": "4.0.2", "cmdName": "h5_zz",
                               "userType": 1,
                               "uuid": "df734215c430467f913c3d3fff579f5e", "userID": "", "platformCode": "h5mobile",
                               "token": ""},
                    "body": {"regionId": regionId}}
            request = Prpcrypt('d3YmI1BUOSE2S2YmalBVZUQ=', "0000000000000000").encrypt(json.dumps(data))
            responseOn = requests.post(urlOn, data={'request': request}, verify=False)
            responseTest = requests.post(urlTest, data={'request': request}, verify=False)
            on = json.dumps(responseOn.json(), sort_keys=True, ensure_ascii=False, indent=4)
            test = json.dumps(responseTest.json(), sort_keys=True, ensure_ascii=False, indent=4)
            diff = difflib.context_diff(on.splitlines(keepends=True), test.splitlines(keepends=True), '线上', '测试')
            print(f'\n************************当前彩种{regionName}************************\n' + ''.join(diff), end="")
コード例 #3
0
ファイル: api_003.py プロジェクト: hamioo66/APITest
def monitorExpert():
    lotteryIds = user_id.keys()
    for lotteryId in lotteryIds:
        for recomUserId in user_id[lotteryId]:
            data = {
                "header": {
                    "appVersion": "1.5.3",
                    "idfa": "",
                    "cmdName": "app_zz",
                    "userId": "0",
                    "uuid": "00000000-5a0e-b2aa-0033-c5870033c587",
                    "token": "",
                    "cmdId": 10000,
                    "platformVersion": "10",
                    "action": "51009",
                    "userType": "0",
                    "brand": "szcapp",
                    "phoneName": "HUAWEI",
                    "platformCode": "Android"
                },
                "body": {
                    "issueName": issuename,
                    "lotteryId": lotteryId,
                    "recomTenantCode": "recom",
                    "recomUserId": recomUserId
                }
            }
            request = Prpcrypt('d3YmI1BUOSE2S2YmalBVZUQ=',
                               "0000000000000000").encrypt(
                                   json.dumps(data, sort_keys=True))
            count = 0
            old_data = []
            response = requests.post(url, data={'request': request}).json()
            #print(response, recomUserId)
            if response['msg'] == '操作成功!':
                lotteryName = response["data"]['lotteryName']
                ls = response["data"]["schemeContentModelList"]
                for i in range(len(ls)):
                    issueName = ls[i]['issueName']
                    playtypeId = ls[i]['playtypeId']
                    playtypeName = ls[i]['playtypeName']
                    if 'dwNumberList' not in ls[i]:
                        numberList = ls[i]['numberList']
                    else:
                        numberList = ls[i]['dwNumberList']

                    if count == 0:
                        old_data = old_data + [
                            recomUserId, issueName, lotteryName, playtypeId,
                            playtypeName, numberList
                        ]
                        #print(old_data)
                        # sql = 'INSERT INTO expert_schedule(lotteryId,lotteryName,recomUserId,issueName,playtypeId,playtypeName,numberList) VALUES ("{}","{}","{}","{}","{}","{}","{}")'.format(
                        #     lotteryId, lotteryName, recomUserId, issueName, playtypeId, playtypeName, numberList)
                        # a = DB()
                        # a.executesql(sql)
                    else:
                        new_data = [
                            recomUserId, issueName, lotteryName, playtypeId,
                            playtypeName, numberList
                        ]
                        dif = [
                            x for x in [old_data + new_data]
                            if x not in old_data
                        ]
                        print(
                            f'专家{recomUserId}{lotteryName}{playtypeName}:{dif}的数据变了'
                        )
                count = count + 1
            else:
                print(f'当前专家{recomUserId}没有最新推荐')
コード例 #4
0
ファイル: api_002.py プロジェクト: hamioo66/APITest
            "token": "",
            "cmdId": 10000,
            "platformVersion": "10",
            "action": "1009",
            "userType": "0",
            "brand": "szcapp",
            "phoneName": "HUAWEI",
            "platformCode": "Android"
        },
        "body": {
            "channelId": channelId,
            "lotteryId": lotteryId,
            "size": 15,
            "timeStamp": ""
        }
    }
    # action
    s = GetKeyValue(o=data, mode='j')
    actionName = s.search_key('action')[0]
    newsList = s.search_key('newsList')
    print(f'接口action={actionName}\n')
    if len(newsList) == 0:
        print('资讯返回数据为空')
    Jdata = json.dumps(data)
    request = Prpcrypt('d3YmI1BUOSE2S2YmalBVZUQ=',
                       "0000000000000000").encrypt(Jdata)
    response = requests.post(url, data={'request': request})
    if response.status_code == 200:
        print(f'接口请求成功,返回json为:{response.json()}\n')
        print(f'响应时间为{response.elapsed.total_seconds()}\n')
コード例 #5
0
ファイル: replyTime.py プロジェクト: hamioo66/APITest
# -*- coding:utf-8 -*-
import requests
from common.util_py3 import Prpcrypt
import json

url = "https://data2c.jdddata.com/number/info/list/v1"
parms = {"header": {"appVersion": "4.0.2", "cmdId": 0, "platformVersion": "4.0.2", "action": 1009, "cmdName": "h5_zz",
                    "uuid": "223b261716f84bc19d3b005ed22b834e", "brand": "szcapp", "platformCode": "h5mobile"},
         "body": {"timeStamp": "", "size": 10, "labels": "2|3|4|5|6|7|8"}}
newParms = Prpcrypt('d3YmI1BUOSE2S2YmalBVZUQ=', "0000000000000000").encrypt(json.dumps(parms))


def get_response(url, data=None, json=None):
    response = requests.post(url, data=data, json=json)
    return response


def parms_to(self, page, size, timestamp, batchNumber):
    self.page = page
    self.size = size
    self.timestamp = timestamp
    self.batchNumber = batchNumber
    if page != 1:
        parms['body']['page'] = str(page)
        parms['body']['size'] = size
        parms['body']['timestamp'] = timestamp
        parms['body']['batchNumber'] = batchNumber
    else:
        parms['body']['page'] = str(1)
    datas = get_response(url, data={'request': newParms})
    newdatas = datas.json()
コード例 #6
0
def AES_parameter(kwargs):
    pc = Prpcrypt('d3YmI1BUOSE2S2YmalBVZUQ=', '0000000000000000')
    dict_to_json = json.dumps(kwargs, sort_keys=True)
    e = pc.encrypt(dict_to_json)
    return e