因此,我很新到晚上,我今天有一种想法,即制作一部对我的背书进行 poll击的文字,并在作改动时发出电子邮件,作为文本寄给我的电话。
电子邮件部分工作,但出于某种原因,我可以拿到投票权,因此我决定,我看看看你是否想在座标。
我的守则如下:
import sys
from stackauth import StackAuth
from stackexchange import Site, StackOverflow
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders
import os
import time
gmail_user = "email@gmail.com"
gmail_pwd = "password"
def mail(to, subject, text):
msg = MIMEMultipart()
msg[ From ] = gmail_user
msg[ To ] = to
msg[ Subject ] = subject
msg.attach(MIMEText(text))
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
mailServer.login(gmail_user, gmail_pwd)
mailServer.sendmail(gmail_user, to, msg.as_string())
# Should be mailServer.quit(), but that crashes...
mailServer.close()
old_rep = None
while True:
user_id = 731221 if len(sys.argv) < 2 else int(sys.argv[1])
print StackOverflow user %d s accounts: % user_id
stack_auth = StackAuth()
so = Site(StackOverflow)
accounts = stack_auth.associated(so, user_id)
REP = accounts[3].reputation
print REP
if REP != old_rep:
old_rep = REP
mail("email@email.com","REP",str(REP))
time.sleep(10)
Currently if you print REP it is right at first, but doesnt update if my rep changes. Ideally it would. Any help is greatly appreciated. Thanks in advance.