ep申请结果状态实时通知爬虫文件

Before I get my employment pass from Singapore, I will check my EP application status by Mom website, the process is so troublesome,so I write a programme to get status auto by Python script.I will not check my status by website, it’s so convenience that I get my finial status by mobile sms.

About how to get status by my mobile, because xxx.139.com will send my email automatically to my sms.

I hope this may be useful for you! XD


# -*- coding: utf-8 -*-
# coding: utf-8
import urllib2
import urllib
import re
import smtplib
import sys
import time
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.image import MIMEImage

def (hour,min,sec):
return hour*3600 + min*60 + sec;

def sendSbmail(to_sbmail,status):
# 发送的邮箱
from_mail='[email protected]'
to_mail=to_sbmail

reload(sys)
sys.setdefaultencoding('gb2312')

msg=MIMEMultipart()
msg['From']=from_mail
msg['To']=to_mail
msg['Subject']='请关注status'+status
# body内容
body='状态'+ status
# 如果图片的话,可以在这里通过HTML格式添加
con=MIMEText('<b>%s</b><br><img src="cid:idreamsky_258.jpg"><br>' % body,'html',_charset="utf-8")
msg.attach(con)
# 配置邮箱的STMP
server=smtplib.SMTP('smtp.126.com')
# 例如 [email protected] 密码
server.login('邮箱名称','邮箱密码')
# 发送邮件给我
server.sendmail(from_mail,to_mail,msg.as_string())
server.quit()

def sendData():
formdata = {"requesterNRICFIN":"E70330000","requesterName":"Duan Duan","travelDocNo":"E70330000","trvDateBirth":"04/12/1994"}
data = urllib.urlencode(formdata)
request = urllib2.Request('https://eponline.mom.gov.sg/epol/PEPOLENQM008SubmitAction.do', data = data)
try:
response = urllib2.urlopen(request)
except Exception as ex:
print ex
return 1
else:
content = response.read()
t = re.search('Pending', content)
a = re.search('Rejected', content)
b = re.search('prove', content)
if t:
print 'Pending',
return 1
if a:
sendSbmail('你的邮箱@me.com', 'Rejected')
return 0
if b:
sendSbmail('你的邮箱@me.com', 'prove')
return 0
return 1
return 1

if __name__ == "__main__":
second = sleeptime(0,0,300);
status = 1
i = 0
while status:
i = i+1
print i,
status = sendData()
time.sleep(second);