|
@@ -0,0 +1,69 @@
|
|
|
+from concurrent.futures import ThreadPoolExecutor
|
|
|
+import requests
|
|
|
+import datetime
|
|
|
+import json
|
|
|
+import pandas as pd
|
|
|
+from sqlalchemy import create_engine
|
|
|
+import uuid
|
|
|
+import traceback
|
|
|
+
|
|
|
+
|
|
|
+db_con_str = "mysql+pymysql://%s:%s@%s:%d/%s" % ("data", "hcst@2021", "139.186.27.96", 4000, "jeecg-boot")
|
|
|
+engine = create_engine(db_con_str, connect_args={'charset': 'utf8'})
|
|
|
+
|
|
|
+
|
|
|
+def send_request(account_id):
|
|
|
+ # url = 'http://139.186.27.96:31012/ai_check_and_up_to_full_creative'
|
|
|
+ # url = 'http://139.186.27.96:31012/ai_up_creative_by_hour'
|
|
|
+ url = 'http://192.168.0.111:31012/ai_up_creative_by_hour'
|
|
|
+ try:
|
|
|
+ request_data = json.dumps({"account_id": account_id})
|
|
|
+ request = requests.post(url, request_data)
|
|
|
+ return json.loads(request.text)
|
|
|
+ except Exception:
|
|
|
+ return "account_id = %s, request = %s, traceback = %s " % (account_id, request, traceback.format_exc())
|
|
|
+
|
|
|
+
|
|
|
+# 0、 打印该定时任务被调用的时间
|
|
|
+unique_uuid = str(uuid.uuid4())
|
|
|
+print("***********", "Test-Start, unique_uuid = ", unique_uuid, datetime.datetime.now(), "**************")
|
|
|
+
|
|
|
+
|
|
|
+# 1、获取已有的账号
|
|
|
+sql = """
|
|
|
+select account_id from ctop_ai_kuaishou_advertiser_strategy where status = 1
|
|
|
+"""
|
|
|
+acc_df = pd.read_sql(sql, engine)
|
|
|
+acc_list = [int(account_id) for account_id in acc_df['account_id'].unique()]
|
|
|
+print(acc_list)
|
|
|
+# 手淘账号: 9792538 登陆账号: 16525841725 密码:a123456
|
|
|
+# 233账号: 9864909 登陆账号: jy20201254@163.com 密码:jysz12345
|
|
|
+# 消消消账号: 6020747 登陆账号: 15715158532 密码:xxx@112233
|
|
|
+# 斗地主账号:8067888 登陆账号: 13699377642 密码:yg@12345
|
|
|
+acc_list = [9881505, 9863696]
|
|
|
+
|
|
|
+# 2、 5个账户一组进行发送请求
|
|
|
+batch_num = 5
|
|
|
+for i in range(0, len(acc_list), batch_num):
|
|
|
+ if i + batch_num < len(acc_list):
|
|
|
+ print(datetime.datetime.now(), tuple(acc_list[i:i+batch_num]))
|
|
|
+ with ThreadPoolExecutor(max_workers=batch_num) as pool:
|
|
|
+ results = pool.map(send_request, tuple(acc_list[i: i+batch_num]))
|
|
|
+ for r in results:
|
|
|
+ print('res = %s' % r)
|
|
|
+ else:
|
|
|
+ with ThreadPoolExecutor(max_workers=batch_num) as pool:
|
|
|
+ print(datetime.datetime.now(), acc_list[i: len(acc_list)])
|
|
|
+ results = pool.map(send_request, tuple(acc_list[i: len(acc_list)]))
|
|
|
+ for r in results:
|
|
|
+ print('res = %s' % r)
|
|
|
+
|
|
|
+# 3、 打印该定时任务结束的时间
|
|
|
+print("***********", "Test-End, unique_uuid = ", unique_uuid, datetime.datetime.now(), "**************")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|