中级农民
- 积分
- 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号通过. Χ
漫长的4个半月,总算熬过来了。期间改了个 Python 3 的脚本,定期扫状态,有变更发邮件,算是第一时间收到消息。. Χ
. 1point 3 acres
- from pyquery import PyQuery as pq
. 1point3acres.com - import requests
- import smtplib
- import os. From 1point 3acres bbs
- import sys ..
- import os.path
- import re
- 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-baidu 1point3acres
- from optparse import OptionParser
- from datetime import datetime, date
- . 1point3acres
- STATUS_OK = 0
- STATUS_ERROR = -1
- FILENAME_LASTSTATUS = os.path.join(sys.path[0], "LAST_STATUS_{0}.txt")
- # ----------------- SETTINGS -------------------. check 1point3acres for more.
- # set up your email sender here
- # example settings: (if you use gmail)
- # email: [email]myname@gmail.com[/email]. check 1point3acres for more.
- # password: xxxx.google и
- # smtpserver: smtp.gmail.com:587
- EMAIL_NOTICE_SENDER = {"email": "", "password": "", "smtpserver": ""}. 1point 3 acres
- def poll_optstatus(casenumber):
- """
- poll USCIS case status given receipt number (casenumber)
- Args:
- param1: casenumber the case receipt number
- . check 1point3acres for more.
- Returns:
- a tuple (status, details) containing status and detailed info
- Raise:
- error:
- """
- headers = {
- 'Accept': 'text/html, application/xhtml+xml, image/jxr, */*',
.google и - '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':
- '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)
- status = doc('h1').text()
- code = STATUS_OK if status else STATUS_ERROR
- details = doc('.text-center p').text()
. ---- - return (code, status, details).
- def send_mail(sentfrom,
- to,. check 1point3acres for more.
- 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))
- 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))-baidu 1point3acres
- 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())
- 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):. From 1point 3acres bbs
- """. From 1point 3acres bbs
- fetch status and update last_status record file,.1point3acres
- 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.1point3acres
- 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. Waral dи,
- else:
- with open(record_filepath, 'r+') as f:
- last_status = f.read().strip(). 1point 3 acres
- # update status on difference
- if status != last_status:
- changed = True
- f.seek(0)
- f.truncate()
- f.write(status). Χ
- return (changed, last_status).1point3acres
- .
- 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:
- return -1
- recv_date = datetime.strptime(datestr, "%B %d, %Y").date().google и
- today = date.today()
- span = (today - recv_date).days ..
- return span
- usage = """
- usage: %prog -c <case_number> [options]
- """
- parser = OptionParser(usage=usage)
- parser.add_option(
- '-c',
- '--casenumber',
- type='string',
- action='store',. check 1point3acres for more.
- dest='casenumber',
- default='YSC1790016391', ..
- help='the USCIS case receipt number you can to query'). 1point3acres
- parser.add_option(
- '-d',
- '--detail',
- action='store_true',.
- dest='detailOn',. 1point3acres
- help="request details about the status returned")
- parser.add_option(
- '--mailto',
- action='store',
- dest='receivers',.1point3acres
- 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"). Waral dи,
- # poll status
- 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}]---------". 1point3acres
- "\nCurrent Status: [{1}]"
- "\nDays since received: [{2}]")
- 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(
- [report, "Previous Status:%s \nChanged: %s" % (laststatus, changed),
- "Current Timestamp: %s " % datetime.now().strftime("%Y-%m-%d %H:%M")])-baidu 1point3acres
- 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)
- .1point3acres
- 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
复制代码 . Χ
. check 1point3acres for more.
效果图
![]()
|
上一篇: 硕士毕业后除OPT以外还有短期居留的方法吗?下一篇: 261号段末尾case制卡超长Timeline+加急经验+改地址+制卡后闯关
|