import datetime import json import requests import simplejson def main(): # account_id = 23212 # day_delta = 10 # video_cnt = 2 # start_date = (datetime.datetime.now() + datetime.timedelta(days=-day_delta)).strftime("%Y-%m-%d %H:%M:%S") # end_date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") # url = "http://192.168.1.8:8080/jeecg-boot/kuaishou/Ai/getNewVideoList" # url = "http://192.168.1.8:8080/jeecg-boot/kuaishou/material/getHistoryVideoList" # video_request_data = {'accountId': account_id, 'startDate': start_date, 'endDate': end_date, 'num': video_cnt, # 'createCount': 10} # print(json.JSONEncoder().encode(video_request_data)) # # 定义请求header # HEADERS = {'Content-Type': 'application/json'} # request = requests.post(url, headers=HEADERS, data=json.JSONEncoder().encode(video_request_data)) # # res_data = simplejson.loads(request.text) # if res_data["code"] != 0: # return "没有视频信息" # request_dict = {"video": res_data['data'], # 'operation_type': 1, # "account_id": 23212, # 'ai_strategy_remark': "打捞历史素材", # "campaign_info": { # "campaign_id": "", # "campaign_name": '广告计划名称-' + str(datetime.datetime.now()), # # "campaign_name": '广告计划名称Test', # "campaign_type": 2 # # }, # 'group_info': {'cpa_bid': 22000, # 'unit_name': '户14-上下滑&信息流-剪辑-低价-低价包邮-活动-年龄18岁以上-单出价' +\ # '-' + str(datetime.datetime.now()), # 'begin_time': str(datetime.date.today())}, # 'creative_info': {'creative_name': '自定义创意', # 'is_sticky': 0, # 需要指定是否为便利贴 # 'creative_category': 20101, # 'creative_tag': ['起量', '搞笑'], # 'action_bar_text': '一键下载', # 'description': '不买亏大了!众多商品低至一元!看看你多花了多少冤枉钱!'}} request_dict = {'video': [{'video_url': 'http://ali-ad.a.yximgs.com/mediacloud/ad_creator/ad_creator_video/peaGh_2xKcxNW4Gtmb210cfbUb3QEbkCA8YaDwl6onc8_qPjHwVFLL_WQc-lHNzH.mp4', 'photo_id': 5229242159171981492, 'signature': '2442bf1940777ec04440b1d9f4d1d66c', 'stat_date': '2020-12-11 20:03:32', 'creative_count': 0, 'channel_type': 1, 'imageList': ['e2e2d8b64c3da90a32ba6d7f1396ae01', '1c193dbcc72a1ead668b4c399c94142f', 'fda49b6fc95451d211c7339a0d361bff', '720bbc330fc61c54167feef0426adb42', 'de74f062c1433ea3340f19a88a3a3628', 'bb7aee58a2d07ba33910dac216d58bd3', '87574be5b74c50c70ebb9014187f779c', '186eaac7ecfe0be1aecd569ac19349b8']}, {'video_url': 'http://ali-ad.a.yximgs.com/mediacloud/ad_creator/ad_creator_video/4j0wlTiFe-TKwAD-8W8whzYZ3ghtSPlx4hYRU212iV7cFw7M36OxSflONsDGEN4c.mp4', 'photo_id': 5202783510598791765, 'signature': '7eacc92a7bf7120868d8c84b0ccad670', 'stat_date': '2020-12-11 20:03:35', 'creative_count': 0, 'channel_type': 1, 'imageList': ['6fc228a2d403f3ab7ff085d8c64b0202', 'e565a5284cb6459f50c108cab46b4d42', '2c817cfd791a34329e3aa351fb494b23', 'c41ccce20eec32b1761d871c6055d61b', 'b48ed29861ce67bea8cca855ef4968c7', '29c6d796c798e809cacc39e5ceb5b68e', '28f32370904f7a990e6285d8c3fb071e', '4211456622d068e1a9689d510f212016']}], 'operation_type': 1, 'account_id': 9743727, 'ai_strategy_remark': '补充遗漏素材', 'campaign_info': {'campaign_id': None, 'campaign_name': '户14-上下滑&信息流-补充遗漏素材-剪辑-低价-低价包邮-活动-年龄18岁以上-单出价-' + str(datetime.datetime.now())}, 'group_info': {'group_name': '户14-上下滑&信息流-补充遗漏素材-剪辑-低价-低价包邮-活动-年龄18岁以上-单出价-' + str(datetime.datetime.now()), 'begin_time': '2021-01-24'}, 'creative_info': {'is_sticky': 0}} add_request_data = json.dumps(request_dict) url = 'http://192.168.1.193:31012/ai_strategy_request' request = requests.post(url, add_request_data) print(request.text) res_data = simplejson.loads(request.text) print(res_data) if __name__ == '__main__': print(main())