-- coding:utf-8 --

import random import re import time import requests from multiprocessing.dummy import Pool as ThreadPool from colorama import init, Fore

init(autoreset=True)

class CKVerification: def init(self): self.ckFile = 'CK.txt' self.ckList = [] self.CKValid = 0 self.ThreadPoolSize = 20

def readCK(self):
    with open(self.ckFile, 'r', encoding='utf-8') as f:
        self.ckList = [record.strip() for record in f]

def checkCK(self, ck):
    sleepTime = random.randint(0, 10)
    time.sleep(sleepTime)
    account, cookies = ck.split('----')
    sMessage = Fore.YELLOW('账号:') + account + ','
    driverCookie = {'BDUSS': cookies}
    headers = {'User-Agent': requests.utils.default_user_agent()}
    baiduURL = 'https://ziyuan.baidu.com/site'
    try:
        r = requests.get(baiduURL, headers=headers, timeout=15, cookies=driverCookie)
        r.raise_for_status()
        sHtml = r.text
        tag = sHtml.find('class="auth-logout">退出</a>')
        if tag != -1:
            usernamePattern = r'class="auth-user" target="_blank">(.*?)</a>'
            username = re.findall(usernamePattern, sHtml)
            message = Fore.GREEN('[+] ') + sMessage + Fore.BLUE('CK is valid: ') + str(username[0])
            self.writeResult(account, cookies, 'True')
            self.CKValid += 1
            print(message)
        else:
            self.writeResult(account, cookies, 'False')
            print(Fore.RED('[-] ') + sMessage + Fore.YELLOW('CK is Expired.'))
    except Exception as e:
        self.writeResult(account, cookies, 'False')
        print(Fore.RED('[-] ') + sMessage + Fore.YELLOW('Request failed.'))

def writeResult(self, name, ck, TF):
    record = f'账号:{name},BDUSS={ck}; BDUSS_FESS={ck},{TF}

' with open('检测结果.csv', 'a+', encoding='utf-8') as f: f.write(record)

def run(self):
    ckList = self.ckList
    pool = ThreadPool(self.ThreadPoolSize)
    pool.map(self.checkCK, ckList)
    pool.close()
    pool.join()

if name == 'main': print(Fore.BLUE(r''' ██████╗ ██╗ ██╗ ██╗███████╗ ██████╗ ███████╗███╗ ██╗███████╗ ██╔══██╗██║ ██║ ██║██╔════╝██╔════╝ ██╔════╝████╗ ██║██╔════╝ ██████╔╝██║ ██║ ██║█████╗ ██║ ███╗█████╗ ██╔██╗ ██║█████╗
██╔══██╗██║ ██║ ██║██╔══╝ ██║ ██║██╔══╝ ██║╚██╗██║██╔══╝
██████╔╝███████╗╚██████╔╝███████╗╚██████╔╝███████╗██║ ╚████║███████╗ ╚═════╝ ╚══════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚══════╝╚═╝ ╚═══╝╚══════╝ 百度站长CK存活检测程序 v1.0.1 Code by: Odin Date: 2023-03-19 updated Contact: Telegram @Sampovalo
''')) CK = CKVerification() CK.readCK() print(Fore.YELLOW(f'总计检测CK数: {len(CK.ckList)}')) CK.run()

百度站长CK存活检测程序优化代码 - 使用Python进行多线程检测

原文地址: https://www.cveoy.top/t/topic/lIIb 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录