吼吼,撸福利的小伙伴看过来,有没有用别名邮箱甚至是同一个邮箱,一次性撸几百几千福利的?然后点邮件点都手软~

之前尝试注册Fort Scott Community College的Edu邮箱,注册了有一百左右。结果看到满满的收件箱,无奈了。这么多邮件(每个里面都包含账号和密码),难道要挨个点开,然后copy、paste么?

分享下之前读取Fort Scott Community College注册邮件内容的Python代码

# coding: utf-8
# By @CodyDoby

import smtplib
import time
import imaplib
import email
import re

ORG_EMAIL   = "@gmail.com"
FROM_EMAIL  = "YouAccName" + ORG_EMAIL
FROM_PWD    = "YourPasswd"
SMTP_SERVER = "imap.gmail.com"
SMTP_PORT   = 993
FILTER_EMAIL = "[email protected]"

# -------------------------------------------------
#
# Utility to read email from Gmail Using Python
#
# ------------------------------------------------

def parse_email(msg_text):
    #print(msg_text)
    sid = re.findall(r"<td><b>([\d]{9})</b></td>", msg_text)
    sidpasswd = re.findall(r"<td><b>[\s]+([\d]{4})</b></td>", msg_text)
    #eadd = re.findall(r"User\sName:</td>\\r\\n[\s]*<td>(\w+)</td>", msg_text)
    eadd = re.findall(r"<td><b>[\s]+(\w+_\w+_[\d]*@students.fortscott.edu)</b></td>", msg_text)
    #passwd = re.findall(r"Password[\s\S]*<td>(\w+)</td>", msg_text)
    passwd = re.findall(r"<td><b>[\s]+([\d]{8})</b></td>", msg_text)
    return sid, sidpasswd, eadd, passwd

def read_email_from_gmail():
    try:
        mail = imaplib.IMAP4_SSL(SMTP_SERVER)
        mail.login(FROM_EMAIL,FROM_PWD)
        mail.select('inbox')

        #rv, data = mail.search(None, 'UNSEEN', 'FROM', '[email protected]')
        #rv, data = mail.search(None, 'FROM', FILTER_EMAIL)
        rv, data = mail.search(None, '(SUBJECT "FSCC Acceptance Letter")')

        if rv != 'OK':
            print("No messages found!")
            return

        mail_ids = data[0]

        id_list = mail_ids.split()

        for i in reversed(id_list):
            typ, data = mail.fetch(i, '(RFC822)' )

            for response_part in data:
                if isinstance(response_part, tuple):
                    msg = email.message_from_string(response_part[1].decode('utf-8'))
                    
                    #print(msg['Subject'])
                    #print(msg['From'])
                    #print(msg.get_payload())
                    sid, sidpasswd, eadd, passwd = parse_email(msg.get_payload())

                    print('%s----%s----%s----%s' % (eadd[0], passwd[0], sid[0], sidpasswd[0]))


    except Exception as e:
        print(str(e))


def main():
    print('Now I will read all message in %s' % FROM_EMAIL)
    read_email_from_gmail()


if __name__ == "__main__":
    main()             

这里用途比较特殊,仅分享下,供参考哦,欢迎交流。

AD:G Suite Education全局管理员或者子号出售中!可联系博主

Last modification:January 8th, 2020 at 10:19 pm
如果觉得我的文章对你有用,请随意赞赏