-- coding:utf-8 --

import re import time from BlueGeneLib import Color, UserAgentPool from multiprocessing.dummy import Pool as ThreadPool

import requests from colorama import init

init(autoreset=True)

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

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

def checkCK(self, ck):
    shortCKPattern = r'BDUSS=[A-Za-z0-9\W_-]+'
    cookie = re.findall(shortCKPattern, ck)
    cookies = cookie[0].replace('BDUSS=', '')
    driverCookie = {'BDUSS': cookies}
    headers = UserAgentPool.get_random_header()
    baiduURL = r'https://ziyuan.baidu.com/site'
    try:
        r = requests.get(baiduURL, headers=headers, timeout=15, cookies=driverCookie)
        r.raise_for_status()
        r.encoding = r.apparent_encoding
        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 = Color.yellow('CK is valid: ') + str(username[0])
            self.CKValid += 1
            print(message)
        else:
            print(Color.red('False'))
    except:
        print(Color.red('Request failed'))

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

if name == 'main': CK = CKVerification() CK.readCK() CK.run()

百度资源网Cookie检测工具

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

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