def eva_time(select, time, productid, pid): param = { "head": { "interface": "eva_time", "msgtype": "request", "remark": "", "version": "0.01" }, "params": { "ip": "127.0.0.1", "cookies": "test", "userid": "1", "select": select, "time": time, "productid": productid, "pid": pid } } # print(json.dumps(param)) url = "http://evaserver.huishoubao.com/rpc/evaluate" headers = {"Content-Type": "application/json;charset=UTF-8"} respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) hsb_response_print(respone=respone)
def batch_get_skuid_info(skuidList): param = { "_head": { "_interface": "batch_get_skuid_info", "_msgType": "request", "_remark": "", "_version": "0.01", "_timestamps": "123", "_invokeId": "111", "_callerServiceId": "112002", "_groupNo": "1" }, "_param": { "skuidList": skuidList } } secret_key = "HKmTk03iDUCLIrFrrQkfOxPiGyGPqxb9" callerserviceid = "112002" url = "http://prdserver.huishoubao.com/product/batch_get_skuid_info" md5value = json.dumps(param) + "_" + secret_key headers = { "Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value), "HSB-OPENAPI-CALLERSERVICEID": callerserviceid } respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) hsb_response_print(respone=respone)
def get_product_sale_evaluate_price(self, productId): (skuList, checkList) = self.product_check_item(productId=productId) # skuList = ['13', '130', '17', '2236', '38', '1091', '2242'] # checkList = ['7420', '7422', '7425', '7428', '7432', '7439', '7443', '7447', '7450', '7452', '7460', '7463', '7465', '7467', '7471', '7475', '7482', '7489', '7491', '7493', '7500', '7507', '7514', '7517', '7522', '7528', '7533', '7537', '7541', '7548', '7555', '7556', '7559', '7562', '7571', '7574', '7578', '7581', '7587', '7589', '7606', '7614'] param = { "_head": { "_interface": "get_product_sale_evaluate_price", "_msgType": "request", "_remark": "hello", "_version": "0.01", "_timestamps": "123", "_invokeId": "111", "_callerServiceId": "112006", "_groupNo": "1" }, "_param": { "productId": productId, "skuList": skuList, "checkList": checkList } } url = "http://codserver.huishoubao.com/detect/get_product_sale_evaluate_price" md5value = json.dumps(param) + "_" + self.secret_key headers = { "Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value), "HSB-OPENAPI-CALLERSERVICEID": self.callerserviceid } respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) hsb_response_print(respone=respone)
def get_eva_pid_channel(pid, channelId): param = { "_head": { "_interface": "get_eva_pid_channel", "_msgType": "request", "_remark": "", "_version": "0.01", "_timestamps": "1525332832", "_invokeId": "SALESDETECT152533283241636", "_callerServiceId": "212013", "_groupNo": "1" }, "_param": { "pid": pid, "channelId": channelId } } secret_key = "CtN4bZr7qYyxygRyP5T0VWMEvWhpH0uf" callerserviceid = "212013" # eva_query 估价查询服务 url = "http://evaserver.huishoubao.com/eva_query/get_eva_pid_channel" md5value = json.dumps(param) + "_" + secret_key headers = { "Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value), "HSB-OPENAPI-CALLERSERVICEID": callerserviceid } respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) hsb_response_print(respone=respone)
def base_price_record_query(recodeId): param = { "_head": { "_interface": "record_query", "_msgType": "request", "_remark": "", "_version": "0.01", "_timestamps": "1525332832", "_invokeId": "test", "_callerServiceId": "116006", "_groupNo": "1" }, "_param": { "recodeId": recodeId } } secret_key = "R2gFCRbILiNhwv3YbtaGceYJlPS5Ku02" callerserviceid = "116006" url = "http://evaserver.huishoubao.com/base_price/record_query" md5value = json.dumps(param) + "_" + secret_key headers = { "Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value), "HSB-OPENAPI-CALLERSERVICEID": callerserviceid } respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) respone.encoding = respone.apparent_encoding # 编码设置 respone_dict = json.loads(respone.text) # 转成字典 hsb_response_print(respone=respone)
def pdt_sku_query(self, productId): param = {"_head": {"_interface": "pdt_sku_query", "_msgType": "request", "_remark": "", "_version": "0.01","_timestamps": "123", "_invokeId": "111", "_callerServiceId": "112002", "_groupNo": "1"},"_param": {"subInterface": "sku_option_combination_get","info": {"productId":productId, "combination":"1"}}} secret_key = "HKmTk03iDUCLIrFrrQkfOxPiGyGPqxb9" callerserviceid = "112002" url = "http://prdserver.huishoubao.com/rpc/new_product_lib" md5value = json.dumps(param) + "_" + secret_key headers = {"Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value),"HSB-OPENAPI-CALLERSERVICEID": callerserviceid} respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) respone.encoding = respone.apparent_encoding # 编码设置 respone_dict = json.loads(respone.text) # 转成字典 optionsList = respone_dict['_body']['_data']['options'] str_sku_answer_list = [] str_Option_answer_desc = '' for info in optionsList: answerList = info['aInfo'] index = random.randint(0, len(answerList) - 1) str_sku_answer_list.append(answerList[index]['aId']) # 以下只为打印输出随机取的估价选项数据 str_Option_answer_desc += '"' + info['qName'] + ":" + answerList[index]['aName'] + '",' str_Option_answer_desc = str_Option_answer_desc[:-1] print('==========>1. 机型标准SKU为(随机取):\n', str_sku_answer_list) print() print('==========>2. 以上SKU答案项ID对应的选项+答案项名称:\n', '{' + str_Option_answer_desc[:-1] + '}' + '\n') return str_sku_answer_list
def check_standard_info(classId, valid, checkKey): param = { "_head": { "_interface": "check_standard_info", "_msgType": "request", "_remark": "", "_version": "0.01", "_timestamps": "123456", "_invokeId": "123456", "_callerServiceId": "112006", "_groupNo": "1" }, "_param": { "classId": classId, "valid": valid, "checkKey": checkKey } } secret_key = "gYt8YHmZVUtq9BxHzmNBQ0Eo7oGi8IKU" callerserviceid = "112006" url = "http://codserver.huishoubao.com/detect/check_standard_info" md5value = json.dumps(param) + "_" + secret_key headers = { "Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value), "HSB-OPENAPI-CALLERSERVICEID": callerserviceid } respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) hsb_response_print(respone=respone)
def v3_eva_option_get(channel_id, product_id, pid): param = { "_head": { "_interface": "eva_option_get", "_msgType": "request", "_remark": "eva_product_v3", "_version": "0.01", "_timestamps": "123", "_invokeId": "eva_product_v3", "_callerServiceId": "816006", "_groupNo": "1" }, "_param": { "channel_id": channel_id, "product_id": product_id, "pid": pid } } secret_key = "dk26kmdasnph0voz69fj0jpv7t3ixev8" callerserviceid = "212006" url = "http://prdserver.huishoubao.com/eva_product_v3/eva_option_get" md5value = json.dumps(param) + "_" + secret_key headers = { "Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value), "HSB-OPENAPI-CALLERSERVICEID": callerserviceid } respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) respone.encoding = respone.apparent_encoding # 编码设置 hsb_response_print(respone=respone)
def get_product_sale_evaluate_price(self, productId, channelId, isBottom): (skuList, checkList) = self.product_check_item_34(productId=productId) # skuList = ['12', '130', '17', '2236', '38', '1091', '1773'] # checkList = ['7418', '7423', '7426', '7428', '7434', '7438', '7442', '7445', '7450', '7453', '7461', '7462', '7464', '7469', '7472', '7474', '7483', '7487', '7490', '7496', '7499', '7508', '7515', '7518', '7523', '7615', '7534', '7536', '7544', '7547', '7554', '7557', '7561', '7563', '7570', '7575', '7578', '7580', '7586', '7590', '7610', '7613'] param = { "_head": { "_interface": "get_product_sale_evaluate_price", "_msgType": "request", "_remark": "hello", "_version": "0.01", "_timestamps": "123", "_invokeId": "111", "_callerServiceId": "112006", "_groupNo": "1" }, "_param": { "productId": productId, "skuList": skuList, "checkList": checkList, "channelId": channelId, "isBottom": isBottom } } url = "http://codserver.huishoubao.com/detect/get_product_sale_evaluate_price" md5value = json.dumps(param) + "_" + self.secret_key headers = { "Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value), "HSB-OPENAPI-CALLERSERVICEID": self.callerserviceid } respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) hsb_response_print(respone=respone)
def v3_product_check_item(self, productId, checkType): param = {"_head": {"_interface": "product_check_item", "_msgType": "request", "_remark": "", "_version": "0.01","_timestamps": "1525332832", "_invokeId": "152533283241636", "_callerServiceId": "216002","_groupNo": "1"},"_param": {"productId": productId, "checkType": checkType, "userId": "1895","freqLimitType": "1", "ip": "127.0.0.1"}} secret_key = "rAfnRwyWfh2N9vXVgWwdpJxaXgOCd8af" callerserviceid = "216002" url = "http://codserver.huishoubao.com/detect_v3/product_check_item" md5value = json.dumps(param) + "_" + secret_key headers = {"Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value),"HSB-OPENAPI-CALLERSERVICEID": callerserviceid} respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) respone.encoding = respone.apparent_encoding # 编码设置 respone_dict = json.loads(respone.text) # 转成字典 checkList = respone_dict['_data']['_data']['checkList'] skuList = respone_dict['_data']['_data']['skuList'] strCheckList = [] strCheckDesc = '' for info_question in checkList: questionList = info_question['questionList'] for info_answer in questionList: answerList = info_answer['answerList'] '''第一种方式:在answerList下随机取1个''' index = random.randint(0, len(answerList) - 1) strCheckList.append(answerList[index]['answerId']) strCheckDesc += '"' + info_answer['questionName'] + '":"' + answerList[index]['answerName'] + '",' '''第二种方式:在answerList下取answerWeight最大的那个''' # index = sorted(answerList, key=lambda x: int(x['answerWeight']), reverse=True)[0] # strCheckList.append(index['answerId']) # strCheckDesc += '"' + info_answer['questionName'] + '":"' + index['answerName'] + '",' return strCheckList, strCheckDesc
def bm_get_product_sku(pid, productId): param = { "_head": { "_interface": "bm_get_product_sku", "_msgType": "request", "_remark": "", "_version": "0.01", "_timestamps": "", "_invokeId": "", "_callerServiceId": "110001", "_groupNo": "1" }, "_param": { "pid": pid, "productId": productId } } secret_key = "c36691ced620bf82ad3fc4642f8a6427" callerserviceid = "110001" url = "http://bmserver.huishoubao.com/bangmai/bm_get_product_sku" md5value = json.dumps(param) + "_" + secret_key headers = { "Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value), "HSB-OPENAPI-CALLERSERVICEID": callerserviceid } respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) hsb_response_print(respone=respone)
def sku_option_combination_get(productId, combination): data = { "server": "product_center", "url": "/rpc/new_product_lib", "interface": "pdt_sku_query", "subInterface": "sku_option_combination_get", "info": { "productId": productId, "combination": combination } } headers = {"Content-Type": "application/json;charset=UTF-8"} url = 'http://evaadmin.huishoubao.com/' respone = session_public_Amc_login().post(url, headers=headers, json=data, proxies=hsb_eva_ipProxy_test()) respone.encoding = respone.apparent_encoding # 编码设置 if combination == '0': # print('响应成功,json格式数据为:\n', respone.text) product_options_dict = respone.json()['_data']['options'] product_aInfo_list = [] for i in product_options_dict: print('SKU选项ID:{0} SKU选项名称:{1}'.format(i['qId'], i['qName'])) print(i['aInfo']) else: # print('响应成功,json格式数据为:\n', respone.text) product_combination_dict = respone.json()['_data']['combination'] for i in product_combination_dict: if i['valid'] == '1': print( '有效组合SKU的答案项aIdList:{0} | fullSkuId:{1} | skuId:{2} | 批发价tradePrice:{3}' .format(i['aIdList'], i['fullSkuId'], i['skuId'], i['tradePrice']))
def classhotget(pid, channel_id): param = { "_head": { "_interface": "classhotget", "_msgType": "request", "_remark": "", "_version": "0.01", "_timestamps": "1234567980", "_invokeId": "111", "_callerServiceId": "112002", "_groupNo": "123" }, "_param": { "pid": pid, "channel_id": channel_id } } secret_key = "HKmTk03iDUCLIrFrrQkfOxPiGyGPqxb9" callerserviceid = "112002" url = "http://prdserver.huishoubao.com/rpc/new_product_lib" md5value = json.dumps(param) + "_" + secret_key headers = { "Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value), "HSB-OPENAPI-CALLERSERVICEID": callerserviceid } respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) hsb_response_print(respone=respone)
def eva_option_get(self, channel_id, product_id, pid): ''' http://wiki.huishoubao.com/web/#/105?page_id=1595 ''' ''' platform_type:使用在不需要 pid 和 channle_id 的场景下,优先使用channel_id 或 pid,可不传''' param = {"_head": {"_interface": "eva_option_get", "_msgType": "request", "_remark": "hello", "_version": "0.01","_timestamps": "123", "_invokeId": "111", "_callerServiceId": "112002", "_groupNo": "1"},"_param": {"channel_id": channel_id, "product_id": product_id, "pid": pid, "platform_type": ""}} secret_key = "HKmTk03iDUCLIrFrrQkfOxPiGyGPqxb9" callerserviceid = "112002" url = "http://prdserver.huishoubao.com/rpc/new_product_lib" md5value = json.dumps(param) + "_" + secret_key headers = {"Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value),"HSB-OPENAPI-CALLERSERVICEID": callerserviceid} respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) respone.encoding = respone.apparent_encoding # 编码设置 respone_dict = json.loads(respone.text) # 转成字典 options_list = respone_dict['_body']['_data']['itemList'] str_options_list = [] str_options_list_show = '' str_options_desc_show = '' for info in options_list: answerList = info['question'] index = random.randint(0, len(answerList) - 1) str_options_list.append(answerList[index]['id']) # 以下只为打印输出随机取的估价选项数据 str_options_list_show += '"' + answerList[index]['id'] + '",' str_options_desc_show += '"' + info['name'] + ":" + answerList[index]['name'] + '",' str_options_list_show = str_options_list_show[:-1] print('估价答案项ID传参数据为(随机取):\n', '{' + str_options_list_show + '}' + '\n') print('以上估价答案项ID对应的选项+答案项名称:\n', '{' + str_options_desc_show[:-1] + '}' + '\n') return str_options_list
def product_check_item_34(self, product_id="41567"): param = { "_head": { "_interface": "product_check_item_34", "_msgType": "request", "_remark": "", "_version": "0.01", "_timestamps": "1525332832", "_invokeId": "152533283241636", "_callerServiceId": self.service_id, "_groupNo": "1" }, "_param": { "productId": product_id } } url = "http://codserver.huishoubao.com/detect/product_check_item" md5value = json.dumps(param) + "_" + self.secret_key headers = { "Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value), "HSB-OPENAPI-CALLERSERVICEID": self.service_id } respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) respone.encoding = respone.apparent_encoding # 编码设置 respone_dict = json.loads(respone.text) # 转成字典 print(respone_dict) checkList = respone_dict['_data']['_data']['checkList'] skuList = respone_dict['_data']['_data']['skuList'] strCheckList = [] strCheckDesc = '' for info in checkList: answerList = info['answerList'] print("答案项列表{}".format(answerList)) '''第一种方式:在answerList下随机取1个''' # index = random.randint(0, len(answerList) - 1) index = 0 strCheckList.append(answerList[index]['answerId']) strCheckDesc += '"' + info['questionName'] + ":" + answerList[ index]['answerName'] + '",' '''第二种方式:在answerList下取answerWeight最大的那个''' # index = sorted(answerList, key=lambda x: int(x['answerWeight']), reverse=True)[0] # strCheckList.append(index['answerId']) # strCheckDesc += '"' + info['questionName'] + ":" + index['answerName'] + '",' strSkuList = [] strSkuDesc = '' for info in skuList: answerList = info['answerList'] # index = random.randint(0, len(answerList) - 1) index = 0 strSkuList.append(answerList[index]['answerId']) strSkuDesc += '"' + info['questionName'] + ":" + answerList[index][ 'answerName'] + '",' # print("====={}\n{}\n\n====={}\n{}".format(strSkuList, strSkuDesc, strCheckList, strCheckDesc)) return strSkuList, strSkuDesc, strCheckList, strCheckDesc
def get_platform_type(): param = { "_head": { "_interface": "get_platform_type", "_msgType": "request", "_remark": "", "_version": "0.01", "_timestamps": "1525332832", "_invokeId": "SALESDETECT152533283241636", "_callerServiceId": "112002", "_groupNo": "1" }, "_param": { "platformId": "", "platformName": "", "groupId": "", "pageSize": "10", "pageIndex": "0" } } secret_key = "HKmTk03iDUCLIrFrrQkfOxPiGyGPqxb9" callerserviceid = "112002" url = "http://prdserver.huishoubao.com/rpc/new_product_lib" md5value = json.dumps(param) + "_" + secret_key headers = { "Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value), "HSB-OPENAPI-CALLERSERVICEID": callerserviceid } respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) hsb_response_print(respone=respone)
def product_check_item_34(self, productId): param = {"_head": {"_interface": "product_check_item_34", "_msgType": "request", "_remark": "", "_version": "0.01","_timestamps": "123456", "_invokeId": "test_zhangjinfa", "_callerServiceId": "112006", "_groupNo": "1"},"_param": {"productId": productId}} secret_key = "gYt8YHmZVUtq9BxHzmNBQ0Eo7oGi8IKU" callerserviceid = "112006" url = "http://codserver.huishoubao.com/detect/product_check_item" md5value = json.dumps(param) + "_" + secret_key headers = {"Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value),"HSB-OPENAPI-CALLERSERVICEID": callerserviceid} respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) respone.encoding = respone.apparent_encoding # 编码设置 respone_dict = json.loads(respone.text) # 转成字典 checkList = respone_dict['_data']['_data']['checkList'] skuList = respone_dict['_data']['_data']['skuList'] strCheckList = [] strCheckDesc = '' for info in checkList: answerList = info['answerList'] '''第一种方式:在answerList下随机取1个''' # index = random.randint(0, len(answerList) - 1) # strCheckList.append(answerList[index]['answerId']) # strCheckDesc += '"' + info['questionName'] + ":" + answerList[index]['answerName'] + '",' '''第二种方式:在answerList下取answerWeight最大的那个''' index = sorted(answerList, key=lambda x: int(x['answerWeight']), reverse=True)[0] strCheckList.append(index['answerId']) strCheckDesc += '"' + info['questionName'] + ":" + index['answerName'] + '",' strSkuList = [] strSkuDesc = '' for info in skuList: answerList = info['answerList'] index = random.randint(0, len(answerList) - 1) strSkuList.append(answerList[index]['answerId']) strSkuDesc += '"' + info['questionName'] + ":" + answerList[index]['answerName'] + '",' return strSkuList, strSkuDesc, strCheckList, strCheckDesc
def evaluate(self, channel_id, product_id, pid, platform_type): param = { "head": { "interface": "evaluate", "msgtype": "request", "remark": "", "version": "0.01" }, "params": { "cookies": "1111", "ip": "127.0.0.1", "pid": pid, "channel_id": channel_id, "productid": product_id, "select": self.eva_option_get(channel_id=channel_id, product_id=product_id, pid=pid, platform_type=platform_type), "userid": "1311" } } url = "http://evaserver.huishoubao.com/rpc/evaluate" headers = {"Content-Type": "application/json"} respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) hsb_response_print(respone=respone)
def product_id_info_get(fproduct_id, fchannel_id): param = { "_head": { "_interface": "product_id_info_get", "_msgType": "request", "_remark": "", "_version": "0.01", "_timestamps": "123", "_invokeId": "111", "_callerServiceId": "110003", "_groupNo": "1" }, "_param": { "fproduct_id": fproduct_id, "fchannel_id": fchannel_id } } secret_key = "Qqn2QV8pcdCIzhpJeE6paatWZAtc2CTK" callerserviceid = "110003" url = "http://prdserver.huishoubao.com/rpc/new_product_lib" md5value = json.dumps(param) + "_" + secret_key headers = { "Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value), "HSB-OPENAPI-CALLERSERVICEID": callerserviceid } respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) hsb_response_print(respone=respone)
def eva_level_price_batch(self,orderId, channelId, platformId, productId, version): skuItem = self.product_lib_sku_to_eva_sku(orderId=orderId, productId=productId) param = {"head":{"interface":"eva_level_price_batch","msgtype":"request","remark":"","version":"0.01"},"params":{"channelId":channelId, "platformId":platformId, "cookies":"111111111","ip":"127.0.0.1","productId":productId, "skuItem":skuItem,"version":version, "userId":"1311"}} url = "http://evaserver.huishoubao.com/rpc/evaluate" headers = {"Content-Type": "application/json;charset=UTF-8"} respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) hsb_response_print(respone=respone)
def get_sku_option_item_by_channel_id(self, productId, platformType, channelId, pid): param = {"_head": {"_interface": "get_sku_option_item_by_channel_id", "_msgType": "request", "_remark": "","_version": "0.01", "_timestamps": "123456", "_invokeId": "123456","_callerServiceId": "112006", "_groupNo": "1"},"_param": {"productId": productId, "platformType": platformType, "channelId": channelId, "pid": pid,"ip": "127.0.0.1"}} url = "http://codserver.huishoubao.com/detect/get_sku_option_item_by_channel_id" md5value = json.dumps(param) + "_" + self.secret_key headers = {"Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value),"HSB-OPENAPI-CALLERSERVICEID": self.callerserviceid} respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) respone.encoding = respone.apparent_encoding # 编码设置 respone_dict = json.loads(respone.text) # 转成字典 options_list = respone_dict['_data']['_data']['itemList'] str_sku_list = [] str_options_list = [] for info in options_list: # conftype:类型id,1-是包括SKU类,2-是单选类,3-是功能性类 conftypeList = info['conftype'] # 分开取,conftypeList == "1",为sku if conftypeList == "1": answerList = info['question'] index = random.randint(0, len(answerList) - 1) str_sku_list.append(answerList[index]['id']) # 分开取,conftypeList == "2" 或者 "3",为机况 else: answerList = info['question'] index = random.randint(0, len(answerList) - 1) str_options_list.append(answerList[index]['id']) # 分开返回sku与机况数据 return str_sku_list, str_options_list
def product_check_item(self, productId): # 【57项标准检测】 "_interface":"product_check_item" # 【闲鱼验机】【53项灰度检】 "_interface":"product_check_item_grayscale" # 【闲鱼无忧购验机1.0】 "_interface":"product_check_item_youpin" # 【闲鱼无忧购验机2.0】 "_interface":"product_check_item_youpin_v2" # 【34项标准检测】 "_interface":"product_check_item_34" param = {"_head": { "_interface":"product_check_item_youpin_v2", "_msgType":"request", "_remark":"", "_version":"0.01", "_timestamps":"123456", "_invokeId":"123456", "_callerServiceId":"112006", "_groupNo":"1" },"_param": {"productId":productId}} url = "http://codserver.huishoubao.com/detect/product_check_item" md5value = json.dumps(param) + "_" + self.secret_key headers = {"Content-Type":"application/json;charset=UTF-8","HSB-OPENAPI-SIGNATURE":Md5Enerypt(md5value),"HSB-OPENAPI-CALLERSERVICEID":self.callerserviceid} respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) respone.encoding = respone.apparent_encoding # 编码设置 respone_dict = json.loads(respone.text) # 转成字典 skuList = respone_dict['_data']['_data']['skuList'] checkList = respone_dict['_data']['_data']['checkList'] strSkuList = [] for info in skuList: answerList = info['answerList'] index = random.randint(0, len(answerList) - 1) strSkuList.append(answerList[index]['answerId']) strCheckList = [] for info in checkList: answerList = info['answerList'] index = random.randint(0, len(answerList) - 1) strCheckList.append(answerList[index]['answerId']) return strSkuList, strCheckList
def v3_sale_evaluate(productId, checkType, evaType, optItem): param = { "_head": { "_interface": "sales_level_generation", "_msgType": "request", "_remark": "", "_version": "0.01", "_timestamps": "1525332832", "_invokeId": "152533283241636", "_callerServiceId": "216002", "_groupNo": "1" }, "_param": { "productId": productId, "checkType": checkType, "evaType": evaType, "optItem": optItem } } secret_key = "rAfnRwyWfh2N9vXVgWwdpJxaXgOCd8af" callerserviceid = "216002" url = "http://codserver.huishoubao.com/detect_v3/sales_level_generation" md5value = json.dumps(param) + "_" + secret_key headers = { "Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value), "HSB-OPENAPI-CALLERSERVICEID": callerserviceid } respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) respone.encoding = respone.apparent_encoding # 编码设置 hsb_response_print(respone=respone)
def brand_ver_get(fkeys, fvalid, fpageindex, fpagesize): param = { "_head": { "_interface": "brand_ver_get", "_msgType": "request", "_remark": "", "_version": "0.01", "_timestamps": "1439261904", "_invokeId": "SALE15216018033998", "_callerServiceId": "112002", "_groupNo": "1" }, "_param": { "fkeys": fkeys, "fvalid": fvalid, "fpageindex": fpageindex, "fpagesize": fpagesize, "fversions": "2" } } secret_key = "HKmTk03iDUCLIrFrrQkfOxPiGyGPqxb9" callerserviceid = "112002" url = "http://prdserver.huishoubao.com/rpc/new_product_lib" md5value = json.dumps(param) + "_" + secret_key headers = { "Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value), "HSB-OPENAPI-CALLERSERVICEID": callerserviceid } respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) hsb_response_print(respone=respone)
def product_lib_sku_to_eva_sku(self, orderId, productId): skuList = self.pdt_sku_query(productId=productId) # skuList = ['14', '130', '18', '2236', '36', '1091', '1083'] param = {"_head":{"_interface":"product_lib_sku_to_eva_sku","_msgType":"request","_remark":"hello","_version":"0.01","_timestamps":"123","_invokeId":"111","_callerServiceId":"112006","_groupNo":"1"},"_param":{ "orderId":orderId, "productId":productId,"skuList":skuList}} secret_key = "gYt8YHmZVUtq9BxHzmNBQ0Eo7oGi8IKU" callerserviceid = "112006" url = "http://codserver.huishoubao.com/detect/product_lib_sku_to_eva_sku" md5value = json.dumps(param) + "_" + secret_key headers = {"Content-Type":"application/json;charset=UTF-8","HSB-OPENAPI-SIGNATURE":Md5Enerypt(md5value),"HSB-OPENAPI-CALLERSERVICEID":callerserviceid} respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) respone.encoding = respone.apparent_encoding # 编码设置 respone_dict = json.loads(respone.text) # 转成字典 sku_list = respone_dict['_data']['_data']['itemList'] str_sku_list = [] str_sku_desc_show = '' for index in range(0, len(sku_list)): str_sku_list.append(sku_list[index]['aId']) # 以下只为打印输出随机取的估价选项数据 str_sku_desc_show += '"' + sku_list[index]['qName'] + ":" + sku_list[index]['aName'] + '",' str_sku_desc_show = str_sku_desc_show[:-1] print('接口响应『json』格式数据为:\n', json.dumps(respone_dict, ensure_ascii=False) + '\n') print('==========>3. 通过商品库sku获取到的估价sku选项为:\n',str_sku_list) print() print('==========>4. 以上估价SKU选项信息未:\n', '{' + str_sku_desc_show + '}' + '\n')
def product_id_info_get(evaFlag, fproduct_id, fchannel_id, ignoreMaxPrice): param = { "_head": { "_interface": "product_id_info_get", "_msgType": "request", "_remark": "", "_version": "0.01", "_timestamps": "123", "_invokeId": "eva_vpc_k8s_zhangjinfa", "_callerServiceId": "112002", "_groupNo": "1" }, "_param": { "evaFlag": evaFlag, "fproduct_id": fproduct_id, "fchannel_id": fchannel_id, "ignoreMaxPrice": ignoreMaxPrice } } secret_key = "HKmTk03iDUCLIrFrrQkfOxPiGyGPqxb9" callerserviceid = "112002" url = "http://prdserver.huishoubao.com/rpc/new_product_lib" md5value = json.dumps(param) + "_" + secret_key headers = { "Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value), "HSB-OPENAPI-CALLERSERVICEID": callerserviceid } respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) hsb_response_print(respone=respone)
def evaluateengineer(self, orderid, isOverInsurance, channel_id, product_id, pid, platform_type): # select = self.eva_option_get(channel_id=channel_id, product_id=product_id, pid=pid, platform_type=platform_type) select = ["12","3246","20","2171","23","223","35","40","53","55","5535","59","63","65","71","6702","6931","9","73","77","7641"] param = {"head":{"interface":"evaluateengineer","msgtype":"request","remark":"","version":"0.01"},"params":{"cookies":"server-evaluate_detect","ip":"127.0.0.1","orderid":orderid, "productId":product_id, "select":select, "isOverInsurance":isOverInsurance, "userid":"1311"}} headers = {"Content-Type":"application/json;charset=UTF-8"} url = "http://evaserver.huishoubao.com/rpc/evaluate" # 大质检 /rpc/evaluate respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) hsb_response_print(respone=respone)
def eva_option_get(channel_id, product_id, pid, business_id, need_default): param = { "_head": { "_interface": "eva_option_get", "_msgType": "request", "_remark": "hello", "_version": "0.01", "_timestamps": "123", "_invokeId": "111", "_callerServiceId": "112002", "_groupNo": "1" }, "_param": { "channel_id": channel_id, "product_id": product_id, "pid": pid, "business_id": business_id, "need_default": need_default } } secret_key = "HKmTk03iDUCLIrFrrQkfOxPiGyGPqxb9" callerserviceid = "112002" url = "http://prdserver.huishoubao.com/rpc/new_product_lib" md5value = json.dumps(param) + "_" + secret_key headers = { "Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value), "HSB-OPENAPI-CALLERSERVICEID": callerserviceid } respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) # response.encoding:从HTTP header中猜测的响应内容编码方式; # response.apparent_encoding:从内容分析出的响应内容的编码方式(备选编码方式) respone.encoding = respone.apparent_encoding # 编码设置 respone_dict = json.loads(respone.text) # 转成字典 print(respone_dict) options_list = respone_dict['_body']['_data']['itemList'] str_options_list = '' str_options_desc = '' for info in options_list: answerList = info['question'] index = random.randint(0, len(answerList) - 1) str_options_list += '"' + answerList[index]['id'] + '",' str_options_desc += '"' + info['name'] + ":" + answerList[index][ 'name'] + '",' str_options_list = str_options_list[:-1] print('接口响应『json』格式数据为:\n', json.dumps(respone_dict, ensure_ascii=False) + '\n') print('大质检【用户】估价【sku】+【机况】答案项ID(随机取):\n', '{' + str_options_list + '}' + '\n') print('以上【sku】+以上【机况】选项名称+答案项名称:\n', '{' + str_options_desc[:-1] + '}' + '\n') print('接口响应时长:{0} 秒'.format(respone.elapsed.total_seconds()))
def base_price_evaluatee(self, channelId, pid, productId, ip, freqLimitType): (str_sku_answer_list, str_Option_answer_desc) = self.pdt_sku_query(productId=productId) # (str_options_list, str_options_list_desc) = self.product_6_eva_option_get(channel_id=channelId, product_id=productId, pid=pid) str_options_list = [ '82', '62', '66', '58', '236', '5530', '55', '78', '7642', '6931', '23', '5534', '224', '20', '1078', '2171', '3245' ] # "evaType":"2" 大质检; "priceType":"1" 销售定价 param = { "_head": { "_interface": "evaluate", "_msgType": "request", "_remark": "", "_version": "0.01", "_timestamps": "1525332832", "_invokeId": "mikingzhang_adjustPrice", "_callerServiceId": "116006", "_groupNo": "1" }, "_param": { "channelId": channelId, "pid": pid, "productId": productId, "evaType": "2", "skuItem": str_sku_answer_list, "optItem": str_options_list, "ip": ip, "userId": "1002", "priceType": "1", "freqLimitType": freqLimitType } } secret_key = "R2gFCRbILiNhwv3YbtaGceYJlPS5Ku02" callerserviceid = "116006" url = "http://bpeserver.huishoubao.com/base_price/evaluate" md5value = json.dumps(param) + "_" + secret_key headers = { "Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value), "HSB-OPENAPI-CALLERSERVICEID": callerserviceid } respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) respone.encoding = respone.apparent_encoding # 编码设置 respone_dict = json.loads(respone.text) # 转成字典 print('========>1.『{0}』 产品的『标准sku,ID』(随机取)为:\n'.format(productId), str_sku_answer_list) print('\n========>2. 以上『标准sku,名称』为:\n', '{' + str_Option_answer_desc[:-1] + '}') # print('\n========>3.『{0}』 产品的『大质检机况17,ID』(随机取)为:\n'.format(productId), str_options_list) # print('\n========>4. 以上『大质检机况17,名称』为:\n', '{' + str_options_list_desc[:-1] + '}') hsb_response_print(respone=respone)
def base_price_evaluatee(self, channelId, pid, productId, ip, freqLimitType): (strSkuList, strSkuDesc, strCheckList, strCheckDesc) = self.product_check_item_57(productId=productId) # strSkuList = ["1083","42","36","2236","130","17","12"] # strCheckList = ["7418","7425","7422","7428","7432","7436","7442","7445","7449","7452","7460","7462","7464","7467","7470","7473","7481","7487","7490","7493","7499","7506","7510","7517","7522","7528","7532","7536","7541","7547","7553","7556","7559","7562","7570","7574","7578","7580","7586","7589","7599","7613"] # "evaType":"1" 标准质检; "priceType":"1" 销售定价 param = { "_head": { "_interface": "evaluate", "_msgType": "request", "_remark": "", "_version": "0.01", "_timestamps": "1525332832", "_invokeId": "mikingzhang_adjustPrice", "_callerServiceId": "116006", "_groupNo": "1" }, "_param": { "channelId": channelId, "pid": pid, "productId": productId, "evaType": "1", "skuItem": strSkuList, "optItem": strCheckList, "ip": ip, "userId": "1002", "priceType": "1", "freqLimitType": freqLimitType } } secret_key = "R2gFCRbILiNhwv3YbtaGceYJlPS5Ku02" callerserviceid = "116006" url = "http://bpeserver.huishoubao.com/base_price/evaluate" md5value = json.dumps(param) + "_" + secret_key headers = { "Content-Type": "application/json;charset=UTF-8", "HSB-OPENAPI-SIGNATURE": Md5Enerypt(md5value), "HSB-OPENAPI-CALLERSERVICEID": callerserviceid } respone = requests.post(url, json=param, headers=headers, proxies=hsb_eva_ipProxy_test()) respone.encoding = respone.apparent_encoding # 编码设置 respone_dict = json.loads(respone.text) # 转成字典 print('========>1.『{0}』 产品的『标准sku,ID』(随机取)为:\n'.format(productId), strSkuList) print('\n========>2. 以上『标准sku,名称』为:\n', '{' + strSkuDesc[:-1] + '}') print( '\n========>3.『{0}』 产品的『检测标准化选项-机况-57,ID』(随机取)为:\n'.format( productId), strCheckList) print('\n========>4. 以上『检测标准化选项-机况-57,名称』为:\n', '{' + strCheckDesc[:-1] + '}') hsb_response_print(respone=respone)