1 回答

TA貢獻(xiàn)1862條經(jīng)驗(yàn) 獲得超6個(gè)贊
您可以找到所有有效令牌,將它們收集到列表中,然后使用有效令牌完全重寫文件。
import requests
valid_tokens = []
with open("tokens.txt","r+") as f:
? ? for line in f:
? ? ? ? token=line.strip("\n")
? ? ? ? url = "https://discordapp.com/api/v6/users/@me/library"
? ? ? ? r = requests.get(url, headers=headers)
? ? ? ? if r.status_code == 200:
? ? ? ? ? ? print(token + " is valid")
? ? ? ? ? ? valid_tokens.append(token)
? ? ? ? else:
? ? ? ? ? ? print("invalid token found "+token)
? ? ? ? ? ? # Could collect the invalid tokens here
with open("tokens.txt","w+") as f:
? ? for i in valid_tokens:
? ? ? ? f.write(i+"\n")
添加回答
舉報(bào)