我需要一个Python脚本,提示输入用户名和密码,并尝试使用这些凭据登录Hotmail,输出它们是否有效。请保留HTML标签。
Hotmail登录!
import poplib
M = poplib.POP3_SSL('pop3.live.com', 995) #Connect to hotmail pop3 server
try:
M.user(raw_input("username: ")) #Get the username from the standar input
M.pass_(raw_input("password: ")) #Get the password from the standar input
except:
print "username or password incorrect"
else:
print "Successful login"
编辑:由于您只需要知道是否可以登录,因此我重新编写了代码。
如果在输入用户名或密码时失去连接,我不知道会发生什么。
如果POP3失败,这是备选方案。只需使用IMAP检查hotmail、live或现在唯一的outlook.com登录,使用python outlook库可以在此处下载:https://github.com/awangga/outlook
import outlook
mail = outlook.Outlook()
mail.checkLogin()
它将尝试使用用户名和密码进行身份验证验证。