查看: 2382| 回复: 2
跳转到指定楼层
上一主题 下一主题
收起左侧

[H1B] H1B Ext SO RFE 终于批了

全局:

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

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 的脚本,定期扫状态,有变更发邮件,算是第一时间收到消息。

  1. from pyquery import PyQuery as pq
  2. import requests
  3. import smtplib
  4. import os
  5. import sys
  6. import os.path. Waral dи,
  7. import re
  8. from email.mime.multipart import MIMEMultipart
  9. from email.mime.base import MIMEBase
  10. from email.mime.text import MIMEText. 1point 3 acres
  11. from email.utils import COMMASPACE, formatdate
  12. from email import encoders
  13. from optparse import OptionParser
  14. from datetime import datetime, date

  15. STATUS_OK = 0. check 1point3acres for more.
  16. STATUS_ERROR = -1
  17. FILENAME_LASTSTATUS = os.path.join(sys.path[0], "LAST_STATUS_{0}.txt"). From 1point 3acres bbs

  18. # ----------------- SETTINGS -------------------. 1point3acres
  19. # set up your email sender here. .и
  20. # example settings: (if you use gmail)
  21. # email: [email]myname@gmail.com[/email]
  22. # password: xxxx
  23. # smtpserver: smtp.gmail.com:587
  24. EMAIL_NOTICE_SENDER = {"email": "", "password": "", "smtpserver": ""}

  25. . check 1point3acres for more.
  26. def poll_optstatus(casenumber):
  27.     """
  28.     poll USCIS case status given receipt number (casenumber)
  29.     Args:
  30.         param1: casenumber the case receipt number
  31. . 1point 3acres
  32.     Returns:
  33.         a tuple (status, details) containing status and detailed info
  34.     Raise:
  35.         error:
  36.     """
  37.     headers = {
  38.         'Accept': 'text/html, application/xhtml+xml, image/jxr, */*',
  39.         'Accept-Encoding': 'gzip, deflate',-baidu 1point3acres
  40.         'Accept-Language':.google  и
  41.         'en-US, en; q=0.8, zh-Hans-CN; q=0.5, zh-Hans; q=0.3',
  42.         'Cache-Control': 'no-cache',
  43.         'Connection': 'Keep-Alive',
  44.         'Content-Type': 'application/x-www-form-urlencoded',
  45.         'Host': 'egov.uscis.gov',
  46.         'Referer': 'https://egov.uscis.gov/casestatus/mycasestatus.do',
  47.         'User-Agent':.1point3acres
  48.         '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'.--
  49.     }
  50.     url = "https://egov.uscis.gov/casestatus/mycasestatus.do"
  51.     data = {"appReceiptNum": casenumber, 'caseStatusSearchBtn': 'CHECK+STATUS'}
  52. .
  53.     res = requests.post(url, data=data, headers=headers). Χ
  54.     doc = pq(res.text).1point3acres
  55.     status = doc('h1').text()
  56.     code = STATUS_OK if status else STATUS_ERROR
  57.     details = doc('.text-center p').text()
  58.     return (code, status, details)

  59. .1point3acres
  60. def send_mail(sentfrom,
  61.               to,.1point3acres
  62.               subject="nil",
  63.               text="",
  64.               files=[],
  65.               server=EMAIL_NOTICE_SENDER['smtpserver'],
  66.               user=EMAIL_NOTICE_SENDER['email'],
  67.               password=EMAIL_NOTICE_SENDER['password']):
  68.     "send email to a list of receivers". .и
  69.     assert type(to) == list. 1point 3acres
  70.     assert type(files) == list. 1point 3 acres
  71.     # get email settings
  72.     if not (server and user and password):
  73.         raise LookupError("Invalid email sending settings"). 1point 3 acres
  74.     msg = MIMEMultipart()
  75.     msg['From'] = sentfrom.--
  76.     msg['To'] = COMMASPACE.join(to).google  и
  77.     msg['Date'] = formatdate(localtime=True)
  78.     msg['Subject'] = subject. Waral dи,

  79.     msg.attach(MIMEText(text))

  80.     for f in files:
  81.         part = MIMEBase('application', "octet-stream")
  82.         part.set_payload(open(f, 'rb').read())
  83.         encoders.encode_base64(part)
  84.         part.add_header('Content-Disposition',
  85.                         'attachment; filename="%s"' % os.path.basename(f))
  86.         msg.attach(part)
  87.     try:
  88.         smtp_s = smtplib.SMTP(server)
  89.         smtp_s.ehlo()
  90.         smtp_s.starttls()
  91.         smtp_s.login(user, password). 1point 3 acres
  92.         smtp_s.sendmail(sentfrom, to, msg.as_string())
  93.         smtp_s.close()
  94.         print("successfully sent the mail !")
  95.     except Exception as e:. From 1point 3acres bbs
  96.         print("failed to send a mail")
    -baidu 1point3acres
  97.         print(str(e))

  98. . Χ

  99. def on_status_fetch(status, casenumber):. ----
  100.     """
  101.     fetch status and update last_status record file,
  102.     or create it if it doesn't exist
  103.     Returns:. ----
  104.         changed flag indicating if status has changed since last time and last status
  105.         (changed, last_status)
  106.         If no prior history is available, then return (False, None)
  107.     """. 1point 3 acres
  108.     # normalize
  109.     status = status.strip()
  110.     record_filepath = FILENAME_LASTSTATUS.format(casenumber)
  111.     changed = False
  112.     last_status = None. Χ
  113.     if not os.path.exists(record_filepath):
  114.         with open(record_filepath, 'w') as f:
  115.             f.write(status)
  116.     # there is prior status, read it and compare with current
  117.     else:
  118.         with open(record_filepath, 'r+') as f:
  119.             last_status = f.read().strip(). ----
  120.             # update status on difference
  121.             if status != last_status:
  122.                 changed = True
  123.                 f.seek(0). .и
  124.                 f.truncate().1point3acres
  125.                 f.write(status)
  126.     return (changed, last_status)


  127. def main():
  128.     def get_days_since_received(status_detail):
  129.         "parse case status and computes number of days elapsed since case-received".--
  130.         date_regex = re.compile(r'^On (\w+ +\d+, \d{4}), .*')
  131.         m = date_regex.match(status_detail)
  132.         datestr = m.group(1)
  133.         if not datestr:.1point3acres
  134.             return -1
  135.         recv_date = datetime.strptime(datestr, "%B %d, %Y").date()
  136.         today = date.today()
  137.         span = (today - recv_date).days.1point3acres
  138.         return span

  139.     usage = """
  140.     usage: %prog -c <case_number> [options]
  141.     """
  142.     parser = OptionParser(usage=usage)-baidu 1point3acres
  143.     parser.add_option(
  144.         '-c',
  145.         '--casenumber',
  146.         type='string',
  147.         action='store',
  148.         dest='casenumber',
  149.         default='YSC1790016391',
  150.         help='the USCIS case receipt number you can to query')
  151.     parser.add_option(
  152.         '-d',. ----
  153.         '--detail',
  154.         action='store_true',
  155.         dest='detailOn',
  156.         help="request details about the status returned")
  157.     parser.add_option(
  158.         '--mailto',
  159.         action='store',
  160.         dest='receivers',
  161.         help=(
  162.             "optionally add one or more emails addresses, separated by comma,"
  163.             " to send the notification mail to")).
  164.     opts, args = parser.parse_args()
  165.     casenumber = opts.casenumber
  166.     if not casenumber:
  167.         raise parser.error("No casenumber is provided")
  168.     # poll status. 1point3acres
  169.     code, status, detail = poll_optstatus(casenumber)
  170.     if code == STATUS_ERROR:
  171.         print("The case number %s is invalid." % casenumber)
  172.         return
  173.     # report format.
  174.     report_format = ("-------  Your USCIS Case [{0}]---------"
  175.                      "\nCurrent Status: [{1}]". From 1point 3acres bbs
  176.                      "\nDays since received: [{2}]")
  177.     days_elapsed = get_days_since_received(detail).--
  178. . 1point3acres.com
  179.     report = report_format.format(casenumber, status, days_elapsed)
  180.     # compare with last status
  181.     changed, laststatus = on_status_fetch(status, casenumber).--
  182.     # generate report
  183.     report = '\n'.join(
  184.         [report, "Previous Status:%s \nChanged: %s" % (laststatus, changed),
  185.          "Current Timestamp: %s " % datetime.now().strftime("%Y-%m-%d %H:%M")])
  186.     if opts.detailOn:
  187.         report = '\n'.join((report, "\nDetail:\n\n%s" % detail))
  188.     # console output.--
  189.     print(report)
  190.     # email notification on status change
  191.     if opts.receivers and changed:
  192.         recv_list = opts.receivers.split(',')
  193.         subject = "Your USCIS Case %s Status Change Notice " % casenumber
  194.         send_mail("myname@gmail.com", recv_list, subject, report)


  195. if __name__ == '__main__':
  196.     main()
复制代码


定时任务
  1. 0 * * * * python3 /home/user/work/poll_uscis.py -c WAC1913xxxxxxxx -d --mailto [email]myname@gmail.com[/email] >>/home/user/work/report.log 2>&1
复制代码



效果图




评分

参与人数 2大米 +5 收起 理由
codingsapien + 2 给你点个赞!
dwt800 + 3 给你点个赞!

查看全部评分


上一篇:硕士毕业后除OPT以外还有短期居留的方法吗?
下一篇:261号段末尾case制卡超长Timeline+加急经验+改地址+制卡后闯关
🔗
mavis108 2019-8-9 04:52:24 | 只看该作者
本楼:
全局:
真棒!恭喜!
回复

使用道具 举报

全局:
恭喜恭喜!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表