69 lines
1.9 KiB
Python
69 lines
1.9 KiB
Python
import dao
|
|
import sys
|
|
import proxy
|
|
import w_token
|
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
import json
|
|
import os
|
|
|
|
f = open('config.json', 'r')
|
|
content = f.read()
|
|
f.close()
|
|
data = json.loads(content)
|
|
workers = data["workers"]
|
|
|
|
|
|
def task(aid, username, password):
|
|
# proxy_host = proxy.get_proxy()
|
|
# t = w_token.get_token(username, password, proxy_host[0], proxy_host[1])
|
|
t = w_token.get_token(username, password, None, None)
|
|
return [aid, username, t]
|
|
|
|
|
|
def main():
|
|
print("输入演出num")
|
|
num = input()
|
|
r = dao.get_apply(num)
|
|
if not r:
|
|
print("演出不存在")
|
|
return
|
|
print("演出信息确认:")
|
|
print(r[0][2], r[0][3])
|
|
t = input("是否确认?(Y/N):")
|
|
if t == "N" or t == "n":
|
|
return
|
|
print("请确认人员名单:")
|
|
u = dao.get_apply_user(r[0][0])
|
|
if not u:
|
|
print("人员不存在")
|
|
return
|
|
print("weverse账号 区号 手机号")
|
|
for row in u:
|
|
print(row[1] + " " + row[2] + " " + row[3])
|
|
t = input("是否确认?(Y/N):")
|
|
if t == "N" or t == "n":
|
|
return
|
|
|
|
count = 0
|
|
with ThreadPoolExecutor(max_workers=workers) as executor:
|
|
# 提交多个任务给线程池
|
|
futures = [executor.submit(task, row[0], row[1], row[4]) for row in u]
|
|
|
|
# 等待所有任务完成并获取结果
|
|
for future in as_completed(futures):
|
|
result = future.result()
|
|
if not result[2]:
|
|
print("applyId:【%s】,username:【%s】获取失败" % (result[0], result[1]))
|
|
continue
|
|
dao.update_token(result[0], result[2])
|
|
count = count + 1
|
|
print("applyId:【%s】,username:【%s】获取成功!!!" % (result[0], result[1]))
|
|
print("一共【%d】人,成功【%d】人" % (len(u), count))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
os.system('chcp 65001')
|
|
main()
|
|
print("按下任意键以退出程序")
|
|
input()
|