From 35d34bd1d66c16a27e14e6c6cdd34ee8056181bf Mon Sep 17 00:00:00 2001 From: liukang <644012909@qq.com> Date: Fri, 21 Feb 2025 14:58:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E7=A8=8B=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.json | 3 ++- main.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index 27c13cf..737f0f0 100644 --- a/config.json +++ b/config.json @@ -1,3 +1,4 @@ { - "executable_path": "C:/Program Files/Google/Chrome/Application/chromedriver.exe" + "executable_path": "C:/Program Files/Google/Chrome/Application/chromedriver.exe", + "workers": 5 } \ No newline at end of file diff --git a/main.py b/main.py index 7fa5737..20ac15f 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,13 @@ import sys import proxy import w_token from concurrent.futures import ThreadPoolExecutor, as_completed +import json + +f = open('config.json', 'r') +content = f.read() +f.close() +data = json.loads(content) +workers = data["workers"] def task(aid, username, password): @@ -36,7 +43,8 @@ def main(): if t == "N" or t == "n": sys.exit() - with ThreadPoolExecutor(max_workers=5) as executor: + count = 0 + with ThreadPoolExecutor(max_workers=workers) as executor: # 提交多个任务给线程池 futures = [executor.submit(task, row[0], row[1], row[4]) for row in u] @@ -47,7 +55,9 @@ def main(): 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__":