易采站長站,站長之家為您整理了Python實(shí)現(xiàn)超星學(xué)習(xí)通簽到(學(xué)習(xí)記錄貼)——(4月1日更新的相關(guān)內(nèi)容。
# ---郵件配置 mail_user = "你的QQ" # 用戶名 mail_pass = "郵箱的口令" # 口令 sender = '發(fā)送者你自己QQ郵箱' receivers = ['接收者'] # 接收郵件,可設(shè)置為你的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 服務(wù) mail_host = "smtp.qq.com" # 設(shè)置服務(wù)器 message = MIMEText(info, 'plain', 'utf-8') message['From'] = Header("守護(hù)最好的豪哥哥", 'utf-8') message['To'] = Header('成功了喲', 'utf-8') subject = 'Python自動發(fā)信' 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("郵件發(fā)送成功") except smtplib.SMTPException: print("Error: 無法發(fā)送郵件") 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 = "http://mooc1-api.chaoxing.com/mycourse/backclazzdata?view=json&rss=1" res = self.session.get(url, headers=self.headers, 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'], 'name': item['content']['course']['data'][0]['name'], 'classid': item['content']['id'] } course_data.append(data) print("課程信息獲取成功:") for item in course_data: # 打印課程 print(str(index) + ".課程名稱:" + item['name']) index += 1 # 查找activePrimaryId def aid_get(self, url): var1 = url.split("&") for var in var1: var2 = var.split("=")以上就是關(guān)于對Python實(shí)現(xiàn)超星學(xué)習(xí)通簽到(學(xué)習(xí)記錄貼)——(4月1日更新的詳細(xì)介紹。歡迎大家對Python實(shí)現(xiàn)超星學(xué)習(xí)通簽到(學(xué)習(xí)記錄貼)——(4月1日更新內(nèi)容提出寶貴意見
|