Python实现超星学习通签到(学习记录贴)2 易采站长站,站长之家为您整理了Python实现超星学习通签到(学习记录贴)——(4月1日更新的相关内容。 # ---邮件配置 mail_user = "你的QQ" # 用户名 mail_pass = "邮箱的口令" # 口令 sender = '发送者你自己QQ邮箱' receivers = ['接收者'] # 接收邮件,可设置为你的QQ邮箱或者其他邮箱 class Operate: def __init__(self, username, password): self.username = username self.password = password self.session = requests.session() self.headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' 'Chrome/74.0.3729.108 Safari/537.36'} def smtp(self,info): # 第三方 SMTP 服务 mail_host = "smtp.qq.com" # 设置服务器 message = MIMEText(info, 'plain', 'utf-8') message['From'] = Header("守护最好的豪哥哥", 'utf-8') message['To'] = Header('成功了哟', 'utf-8') subject = 'Python自动发信' message['Subject'] = Header(subject, 'utf-8') try: smtpObj = smtplib.SMTP() smtpObj.connect(mail_host, 25) # 25 为 SMTP 端口号 smtpObj.login(mail_user, mail_pass) smtpObj.sendmail(sender, receivers, message.as_string()) print("邮件发送成功") except smtplib.SMTPException: print("Error: 无法发送邮件") def Cookie_get(self): # 获取cookie url = 'https://passport2-api.chaoxing.com/v11/loginregister' data = { 'uname': self.username, 'code': self.password } cookie_jar = self.session.post(url=url, data=data, headers=self.headers).cookies cookie_t = requests.utils.dict_from_cookiejar(cookie_jar) return cookie_t def Course_get(self): global course_data, index url res = = self.session.get(url, "http://mooc1-headers=self.headers, api.chaoxing.com/mycourse/backclazzdata?view=json&rss=1" cookies=cookie) cdata = json.loads(res.text) if cdata['result'] != 1: print("课程列表获取失败") for item in cdata['channelList']: if "course" not in item['content']: continue data = { 'courseid': item['content']['course']['data'][0]['id'], 本文来源:https://www.wddqw.com/doc/8bd61c7c29f90242a8956bec0975f46526d3a77b.html