def login(wf, args):
try:
username = wf.get_password(USERNAME_KEY)
password = wf.get_password(PASSWORD_KEY)
except PasswordNotFound:
notify(
"Can't login",
"You need to set your username and password before login",
)
return 1
# Login code copied from
# https://github.com/helloqiu/mianliao-login/blob/master/mianliao.py
session = requests.Session()
session.headers = ML_HEADERS
session.verify = False # SB Mianliao
if session.get(ML_URL).status_code != 200:
notify(
"Can't login",
"Can not connect to the Mianliao Auth Server!",
)
return 1
session.post(
ML_URL,
data='username=%s&password=%s&action=login' % (username, password),
)
r = session.post(ML_URL, data={
'ua': USERAGENT,
'sw': 1280,
'sh': 720,
'ww': 1280,
'wh': 720
})
wf.logger.debug(r.text)
if u"?????????" in r.text:
notify(
"Can't login",
"Mianliao Auth Server is down."
)
return 1
if u"????" in r.text:
notify(
"Login Success!",
)
return 0
notify(
"Can't login",
"Maybe wrong username or password?"
)
评论列表
文章目录