中级农民
- 积分
- 102
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2019-6-20
- 最后登录
- 1970-1-1
|
注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
H1B 第一次延期
3月6号提交,F记律师忘了PP4月30号补PP. Waral dи,
5月2号收件
5月7号要求RFE
5月14号律师通知 RFE 为 SO
开始准备材料
7月18号提交回复
7月19号收件
7月23号通过
.1point3acres
漫长的4个半月,总算熬过来了。期间改了个 Python 3 的脚本,定期扫状态,有变更发邮件,算是第一时间收到消息。
- from pyquery import PyQuery as pq
- import requests
- import smtplib
- import os
- import sys
- import os.path. Waral dи,
- import re
- from email.mime.multipart import MIMEMultipart
- from email.mime.base import MIMEBase
- from email.mime.text import MIMEText. 1point 3 acres
- from email.utils import COMMASPACE, formatdate
- from email import encoders
- from optparse import OptionParser
- from datetime import datetime, date
- STATUS_OK = 0. check 1point3acres for more.
- STATUS_ERROR = -1
- FILENAME_LASTSTATUS = os.path.join(sys.path[0], "LAST_STATUS_{0}.txt"). From 1point 3acres bbs
- # ----------------- SETTINGS -------------------. 1point3acres
- # set up your email sender here. .и
- # example settings: (if you use gmail)
- # email: [email]myname@gmail.com[/email]
- # password: xxxx
- # smtpserver: smtp.gmail.com:587
- EMAIL_NOTICE_SENDER = {"email": "", "password": "", "smtpserver": ""}
- . check 1point3acres for more.
- def poll_optstatus(casenumber):
- """
- poll USCIS case status given receipt number (casenumber)
- Args:
- param1: casenumber the case receipt number
- . 1point 3acres
- Returns:
- a tuple (status, details) containing status and detailed info
- Raise:
- error:
- """
- headers = {
- 'Accept': 'text/html, application/xhtml+xml, image/jxr, */*',
- 'Accept-Encoding': 'gzip, deflate',-baidu 1point3acres
- 'Accept-Language':.google и
- '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':.1point3acres
- '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). Χ
- doc = pq(res.text).1point3acres
- status = doc('h1').text()
- code = STATUS_OK if status else STATUS_ERROR
- details = doc('.text-center p').text()
- return (code, status, details)
- .1point3acres
- def send_mail(sentfrom,
- to,.1point3acres
- 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. 1point 3acres
- assert type(files) == list. 1point 3 acres
- # get email settings
- if not (server and user and password):
- raise LookupError("Invalid email sending settings"). 1point 3 acres
- msg = MIMEMultipart()
- msg['From'] = sentfrom.--
- msg['To'] = COMMASPACE.join(to).google и
- msg['Date'] = formatdate(localtime=True)
- msg['Subject'] = subject. Waral dи,
- msg.attach(MIMEText(text))
- 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',
- '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). 1point 3 acres
- smtp_s.sendmail(sentfrom, to, msg.as_string())
- smtp_s.close()
- print("successfully sent the mail !")
- except Exception as e:. From 1point 3acres bbs
- print("failed to send a mail")
-baidu 1point3acres - 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)
- """. 1point 3 acres
- # normalize
- status = status.strip()
- 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:
- f.write(status)
- # 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().1point3acres
- f.write(status)
- return (changed, last_status)
- 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)
- if not datestr:.1point3acres
- return -1
- recv_date = datetime.strptime(datestr, "%B %d, %Y").date()
- today = date.today()
- span = (today - recv_date).days.1point3acres
- return span
- usage = """
- usage: %prog -c <case_number> [options]
- """
- parser = OptionParser(usage=usage)-baidu 1point3acres
- parser.add_option(
- '-c',
- '--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=(
- "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. 1point3acres
- code, status, detail = poll_optstatus(casenumber)
- if code == STATUS_ERROR:
- print("The case number %s is invalid." % casenumber)
- return
- # report format.
- report_format = ("------- Your USCIS Case [{0}]---------"
- "\nCurrent Status: [{1}]". From 1point 3acres bbs
- "\nDays since received: [{2}]")
- days_elapsed = get_days_since_received(detail).--
- . 1point3acres.com
- report = report_format.format(casenumber, status, days_elapsed)
- # compare with last status
- changed, laststatus = on_status_fetch(status, casenumber).--
- # generate report
- report = '\n'.join(
- [report, "Previous Status:%s \nChanged: %s" % (laststatus, changed),
- "Current Timestamp: %s " % datetime.now().strftime("%Y-%m-%d %H:%M")])
- if opts.detailOn:
- report = '\n'.join((report, "\nDetail:\n\n%s" % detail))
- # console output.--
- print(report)
- # email notification on status change
- 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+加急经验+改地址+制卡后闯关
|