中级农民
- 积分
- 102
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2019-6-20
- 最后登录
- 1970-1-1
|
注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
H1B 第一次延期.--
3月6号提交,F记律师忘了PP4月30号补PP
5月2号收件
5月7号要求RFE
5月14号律师通知 RFE 为 SO
开始准备材料
7月18号提交回复
7月19号收件
7月23号通过. Χ
. From 1point 3acres bbs
漫长的4个半月,总算熬过来了。期间改了个 Python 3 的脚本,定期扫状态,有变更发邮件,算是第一时间收到消息。
- from pyquery import PyQuery as pq
- import requests.1point3acres
- import smtplib
- import os
- import sys
- import os.path
- import re. 1point 3acres
- from email.mime.multipart import MIMEMultipart
- from email.mime.base import MIMEBase
- from email.mime.text import MIMEText
- from email.utils import COMMASPACE, formatdate
- from email import encoders
- from optparse import OptionParser. 1point 3acres
- from datetime import datetime, date
- STATUS_OK = 0
- STATUS_ERROR = -1
- FILENAME_LASTSTATUS = os.path.join(sys.path[0], "LAST_STATUS_{0}.txt")
- # ----------------- SETTINGS -------------------
- # set up your email sender here
- # example settings: (if you use gmail). Waral dи,
- # email: [email]myname@gmail.com[/email]
- # password: xxxx
- # smtpserver: smtp.gmail.com:587
- EMAIL_NOTICE_SENDER = {"email": "", "password": "", "smtpserver": ""}
- . 1point3acres.com
- . 1point3acres.com
- def poll_optstatus(casenumber):
- """
- poll USCIS case status given receipt number (casenumber)
- Args:
- param1: casenumber the case receipt number
- Returns:. From 1point 3acres bbs
- a tuple (status, details) containing status and detailed info
- Raise:
- error:
- """
- headers = {
- 'Accept': 'text/html, application/xhtml+xml, image/jxr, */*',
- 'Accept-Encoding': 'gzip, deflate',
- 'Accept-Language':
- 'en-US, en; q=0.8, zh-Hans-CN; q=0.5, zh-Hans; q=0.3',
- 'Cache-Control': 'no-cache',
- 'Connection': 'Keep-Alive',
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'Host': 'egov.uscis.gov',
- 'Referer': 'https://egov.uscis.gov/casestatus/mycasestatus.do',
- 'User-Agent':. From 1point 3acres bbs
- 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586'
- }
- url = "https://egov.uscis.gov/casestatus/mycasestatus.do". Χ
- data = {"appReceiptNum": casenumber, 'caseStatusSearchBtn': 'CHECK+STATUS'}
- res = requests.post(url, data=data, headers=headers). check 1point3acres for more.
- doc = pq(res.text)
- status = doc('h1').text()
- code = STATUS_OK if status else STATUS_ERROR
- details = doc('.text-center p').text()
- return (code, status, details)
- . Waral dи,
- def send_mail(sentfrom,
- to,
- subject="nil",
- text="",
- files=[],
- server=EMAIL_NOTICE_SENDER['smtpserver'],
- user=EMAIL_NOTICE_SENDER['email'],
- password=EMAIL_NOTICE_SENDER['password']):
- "send email to a list of receivers"
- assert type(to) == list
- assert type(files) == list
- # get email settings
- if not (server and user and password):
- raise LookupError("Invalid email sending settings")
- msg = MIMEMultipart()
- msg['From'] = sentfrom
- msg['To'] = COMMASPACE.join(to)
- msg['Date'] = formatdate(localtime=True)
- msg['Subject'] = subject.
- msg.attach(MIMEText(text)). 1point3acres
. - for f in files: ..
- part = MIMEBase('application', "octet-stream")
- part.set_payload(open(f, 'rb').read()). ----
- encoders.encode_base64(part)
- part.add_header('Content-Disposition',-baidu 1point3acres
- 'attachment; filename="%s"' % os.path.basename(f))
- msg.attach(part). .и
- try:
- smtp_s = smtplib.SMTP(server)
- smtp_s.ehlo()
- smtp_s.starttls()
- smtp_s.login(user, password)
- smtp_s.sendmail(sentfrom, to, msg.as_string()). 1point 3 acres
- smtp_s.close()
- print("successfully sent the mail !")
- except Exception as e:
- print("failed to send a mail")
- print(str(e))
- def on_status_fetch(status, casenumber):
- """
- fetch status and update last_status record file,
- or create it if it doesn't exist
- Returns:
- changed flag indicating if status has changed since last time and last status
- (changed, last_status)
- If no prior history is available, then return (False, None)
- """
- # normalize
- status = status.strip(). From 1point 3acres bbs
- record_filepath = FILENAME_LASTSTATUS.format(casenumber)
- changed = False
- last_status = None
- if not os.path.exists(record_filepath):
- with open(record_filepath, 'w') as f:.1point3acres
- f.write(status). Waral dи,
- # there is prior status, read it and compare with current
- else:
. - with open(record_filepath, 'r+') as f:
- last_status = f.read().strip()
- # update status on difference
- if status != last_status:
- changed = True
- f.seek(0)
- f.truncate()
- f.write(status)
- return (changed, last_status)
- . check 1point3acres for more.
- def main():
- def get_days_since_received(status_detail):
- "parse case status and computes number of days elapsed since case-received"
- date_regex = re.compile(r'^On (\w+ +\d+, \d{4}), .*')
- m = date_regex.match(status_detail)
- datestr = m.group(1). 1point 3acres
- if not datestr:
- return -1
- recv_date = datetime.strptime(datestr, "%B %d, %Y").date()
- today = date.today(). 1point3acres
- span = (today - recv_date).days
- return span
- usage = """
- usage: %prog -c <case_number> [options] ..
- """
- parser = OptionParser(usage=usage)
- parser.add_option(. check 1point3acres for more.
- '-c',. 1point3acres.com
- '--casenumber',
- type='string',
- action='store',
- dest='casenumber',. ----
- default='YSC1790016391',
- help='the USCIS case receipt number you can to query')
- parser.add_option(
- '-d',
- '--detail',
- action='store_true',
- dest='detailOn',
- help="request details about the status returned")
- parser.add_option(
- '--mailto',
- action='store',
- dest='receivers',
- help=(. Waral dи,
- "optionally add one or more emails addresses, separated by comma,"
- " to send the notification mail to"))
- opts, args = parser.parse_args()
- casenumber = opts.casenumber
- if not casenumber:
- raise parser.error("No casenumber is provided")
- # poll status
. 1point 3 acres - code, status, detail = poll_optstatus(casenumber)
- if code == STATUS_ERROR:
- print("The case number %s is invalid." % casenumber). 1point3acres.com
- return
- # report format
- report_format = ("------- Your USCIS Case [{0}]---------"
- "\nCurrent Status: [{1}]"
- "\nDays since received: [{2}]")
. 1point3acres.com - days_elapsed = get_days_since_received(detail)
- report = report_format.format(casenumber, status, days_elapsed)
- # compare with last status
- changed, laststatus = on_status_fetch(status, casenumber)
- # generate report
- report = '\n'.join(. Waral dи,
- [report, "Previous Status:%s \nChanged: %s" % (laststatus, changed),. check 1point3acres for more.
- "Current Timestamp: %s " % datetime.now().strftime("%Y-%m-%d %H:%M")]). From 1point 3acres bbs
- if opts.detailOn:
- report = '\n'.join((report, "\nDetail:\n\n%s" % detail))
- # console output. Χ
- print(report)
- # email notification on status change-baidu 1point3acres
- if opts.receivers and changed:
- recv_list = opts.receivers.split(',')
- subject = "Your USCIS Case %s Status Change Notice " % casenumber
- send_mail("myname@gmail.com", recv_list, subject, report)
- if __name__ == '__main__':
- main()
复制代码 .--
定时任务
- 0 * * * * python3 /home/user/work/poll_uscis.py -c WAC1913xxxxxxxx -d --mailto [email]myname@gmail.com[/email] >>/home/user/work/report.log 2>&1
复制代码
效果图.--
![]()
|
上一篇: 硕士毕业后除OPT以外还有短期居留的方法吗?下一篇: 261号段末尾case制卡超长Timeline+加急经验+改地址+制卡后闯关
|