本帖最后由 lennydada 于 2020-7-3 18:39 编辑
于2020/7/1-3日编写,仅供个人学习参考,请勿用于非法途径。
[Python] 纯文本查看 复制代码 import requests
import time
# -------------获取验证码所需参数
# code地址
codeurl = 'https://nuc.api.mgtv.com/v1/LoginCaptcha?'
# code参数
codedata = {
'_support':'10000000',
'deviceid':'1e92894d-daac-497d-b4d9-25d41da0568e',
'appVersion':'pcweb-6.3.0.gray',
'dname':'',
'src':'intelmgtv',
'invoker':'pcweb',
'username':'',
'smscode':'86',
't':'',
}
# -------------post登陆所需参数
# post地址
loginurl = 'https://nuc.api.mgtv.com/v1/Login'
# post提交数据
logindata = {
'_support':'10000000',
'deviceid':'1e92894d-daac-497d-b4d9-25d41da0568e',
'appVersion':'pcweb-6.3.0.gray',
'dname':'',
'src':'intelmgtv',
'invoker':'pcweb',
'username':'',
'password':'',
'smscode':'86',
'captcha':'',
}
# -------------获取验证码
# 时间戳
t = int(round(time.time() * 1000))
# 替换数据
codedata['username'] = '@账号'
codedata['t'] = t
# get验证码写出文件
coderes = requests.get(codeurl,params=codedata)
with open('code.png', 'wb') as file:
file.write(coderes.content)
# -------------验证码识别
# 验证码处理
# 暂不放出
# 验证码识别
# 暂不放出
# -------------账号登入
# 替换数据
logindata['username'] = '@账号'
logindata['password'] = '@密码'
logindata['captcha'] = '@验证码'
# post提交login
loginres =requests.post(loginurl,logindata)
# 结果判断
# -------------账号登出
# get提交logout
requests.get('https://i.mgtv.com/account/logout?from=https://www.mgtv.com/#')
|