-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QoL: Format code with `black`
- Loading branch information
Showing
22 changed files
with
1,371 additions
and
539 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,53 @@ | ||
from pyncm.apis.login import LoginViaCellphone,SetSendRegisterVerifcationCodeViaCellphone,GetRegisterVerifcationStatusViaCellphone | ||
from pyncm import GetCurrentSession,DumpSessionAsString, LoadSessionFromString, SetCurrentSession | ||
from pyncm.apis.login import ( | ||
LoginViaCellphone, | ||
SetSendRegisterVerifcationCodeViaCellphone, | ||
GetRegisterVerifcationStatusViaCellphone, | ||
) | ||
from pyncm import ( | ||
GetCurrentSession, | ||
DumpSessionAsString, | ||
LoadSessionFromString, | ||
SetCurrentSession, | ||
) | ||
from pprint import pprint | ||
|
||
|
||
def login(): | ||
import inquirer | ||
|
||
query = inquirer.prompt( | ||
[ | ||
inquirer.Text("phone", message="手机号"), | ||
inquirer.Text("phone", message="手机号"), | ||
inquirer.Text("ctcode", message="国家代码(默认86)"), | ||
] | ||
) | ||
phone,ctcode = query["phone"], query["ctcode"] or 86 | ||
if inquirer.confirm('使用手机验证码登陆?'): | ||
result = SetSendRegisterVerifcationCodeViaCellphone(phone,ctcode) | ||
if not result.get('code',0) == 200: | ||
phone, ctcode = query["phone"], query["ctcode"] or 86 | ||
if inquirer.confirm("使用手机验证码登陆?"): | ||
result = SetSendRegisterVerifcationCodeViaCellphone(phone, ctcode) | ||
if not result.get("code", 0) == 200: | ||
pprint(result) | ||
else: | ||
print('[-] 已发送验证码') | ||
print("[-] 已发送验证码") | ||
while True: | ||
captcha = inquirer.text("输入验证码") | ||
verified = GetRegisterVerifcationStatusViaCellphone(phone,captcha,ctcode) | ||
verified = GetRegisterVerifcationStatusViaCellphone(phone, captcha, ctcode) | ||
pprint(verified) | ||
if verified.get('code',0) == 200: | ||
print('[-] 验证成功') | ||
if verified.get("code", 0) == 200: | ||
print("[-] 验证成功") | ||
break | ||
result = LoginViaCellphone(phone,captcha=captcha,ctcode=ctcode) | ||
result = LoginViaCellphone(phone, captcha=captcha, ctcode=ctcode) | ||
pprint(result) | ||
else: | ||
password = inquirer.password("输入密码") | ||
result = LoginViaCellphone(phone,password=password,ctcode=ctcode) | ||
result = LoginViaCellphone(phone, password=password, ctcode=ctcode) | ||
pprint(result) | ||
print('[!] 登录态 Session:',DumpSessionAsString(GetCurrentSession())) | ||
print('[-] 此后可通过 SetCurrentSession(LoadSessionFromString("PYNCMe...")) 恢复当前登录态') | ||
print("[!] 登录态 Session:", DumpSessionAsString(GetCurrentSession())) | ||
print( | ||
'[-] 此后可通过 SetCurrentSession(LoadSessionFromString("PYNCMe...")) 恢复当前登录态' | ||
) | ||
return True | ||
|
||
|
||
if __name__ == "__main__": | ||
print("[-] 登录测试") | ||
assert login(), "登陆失败" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.