【发布时间】:2021-10-11 19:15:26
【问题描述】:
这是代码,我正在一个测试网站上使用它。它生成随机密码并将它们保存到文本文件中。 2个问题:第一个是文本文件没有保存所有密码尝试,第二个是它重做以前的密码尝试
PASSWORD = ""
ATTEMPTS = 0
MaxAttempts = 9999;
driver.get("https://test")
driver.find_element_by_name("login").send_keys("testacc")\
LENGTH = range(8,16)
mouse_pos = pygame.mouse.get_pos()
PASSWORD = ''.join(random.choice(string.ascii_letters + string.digits) for _ in (LENGTH))
with open('Attempts.txt', 'w') as f:
f.write(PASSWORD)
if driver.current_url != ("https://test"):
print(PASSWORD, " is the password")
while(driver.current_url == ('https://test')):
else:
with open('Attempts.txt', 'w') as f:
f.write(PASSWORD)
PASSWORD = ''.join(random.choice(string.ascii_letters + string.digits) for _ in (LENGTH))
driver.find_element_by_name("password").send_keys(PASSWORD)
ATTEMPTS = ATTEMPTS + 1
LASTTRIEDPASSWORD = PASSWORD
print(LASTTRIEDPASSWORD, "This is the ", ATTEMPTS, " Attempt")
【问题讨论】:
-
这里有很多问题。你的长度没有被选中,你每次都会有 8 个 (len(8,16)) 个字母。您只是从可能的密码中随机选择一个密码,当然它会重复,但我认为您不会发现重复,因为 62^8 是 218 万亿...