百度云盘Cookie校验工具 - 高效检测你的Cookie有效性
-- coding:utf-8 --
import re import time from BlueGeneLib import Color, UserAgentPool, ProxyPool 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}
UAC = UserAgentPool.get()
headers = {'User-Agent': UAC}
proxy = ProxyPool.get()
proxies = {'http': 'http://' + proxy, 'https': 'https://' + proxy}
baiduURL = r'https://ziyuan.baidu.com/site'
try:
r = requests.get(baiduURL, headers=headers, timeout=15, cookies=driverCookie, proxies=proxies)
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()
原文地址: https://www.cveoy.top/t/topic/lIGL 著作权归作者所有。请勿转载和采集!