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

[H1B] H1B Ext SO RFE 终于批了

全局:

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

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

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

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

  15. STATUS_OK = 0
  16. STATUS_ERROR = -1
  17. FILENAME_LASTSTATUS = os.path.join(sys.path[0], "LAST_STATUS_{0}.txt")

  18. # ----------------- SETTINGS -------------------
  19. # set up your email sender here
  20. # example settings: (if you use gmail). Waral dи,
  21. # email: [email]myname@gmail.com[/email]
  22. # password: xxxx
  23. # smtpserver: smtp.gmail.com:587
  24. EMAIL_NOTICE_SENDER = {"email": "", "password": "", "smtpserver": ""}
  25. . 1point3acres.com
  26. . 1point3acres.com
  27. def poll_optstatus(casenumber):
  28.     """
  29.     poll USCIS case status given receipt number (casenumber)
  30.     Args:
  31.         param1: casenumber the case receipt number

  32.     Returns:. From 1point 3acres bbs
  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',
  40.         'Accept-Language':
  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':. From 1point 3acres bbs
  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.     res = requests.post(url, data=data, headers=headers). check 1point3acres for more.
  53.     doc = pq(res.text)
  54.     status = doc('h1').text()
  55.     code = STATUS_OK if status else STATUS_ERROR
  56.     details = doc('.text-center p').text()
  57.     return (code, status, details)
  58. . Waral dи,

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

  78.     msg.attach(MIMEText(text)). 1point3acres

  79. .
  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',-baidu 1point3acres
  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)
  92.         smtp_s.sendmail(sentfrom, to, msg.as_string()). 1point 3 acres
  93.         smtp_s.close()
  94.         print("successfully sent the mail !")
  95.     except Exception as e:
  96.         print("failed to send a mail")
  97.         print(str(e))


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

  126. . check 1point3acres for more.
  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). 1point 3acres
  133.         if not datestr:
  134.             return -1
  135.         recv_date = datetime.strptime(datestr, "%B %d, %Y").date()
  136.         today = date.today(). 1point3acres
  137.         span = (today - recv_date).days
  138.         return span

  139.     usage = """
  140.     usage: %prog -c <case_number> [options] ..
  141.     """
  142.     parser = OptionParser(usage=usage)
  143.     parser.add_option(. check 1point3acres for more.
  144.         '-c',. 1point3acres.com
  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=(. Waral dи,
  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
    . 1point 3 acres
  169.     code, status, detail = poll_optstatus(casenumber)
  170.     if code == STATUS_ERROR:
  171.         print("The case number %s is invalid." % casenumber). 1point3acres.com
  172.         return
  173.     # report format
  174.     report_format = ("-------  Your USCIS Case [{0}]---------"
  175.                      "\nCurrent Status: [{1}]"
  176.                      "\nDays since received: [{2}]")
    . 1point3acres.com
  177.     days_elapsed = get_days_since_received(detail)

  178.     report = report_format.format(casenumber, status, days_elapsed)
  179.     # compare with last status
  180.     changed, laststatus = on_status_fetch(status, casenumber)
  181.     # generate report
  182.     report = '\n'.join(. Waral dи,
  183.         [report, "Previous Status:%s \nChanged: %s" % (laststatus, changed),. check 1point3acres for more.
  184.          "Current Timestamp: %s " % datetime.now().strftime("%Y-%m-%d %H:%M")]). From 1point 3acres bbs
  185.     if opts.detailOn:
  186.         report = '\n'.join((report, "\nDetail:\n\n%s" % detail))
  187.     # console output. Χ
  188.     print(report)
  189.     # email notification on status change-baidu 1point3acres
  190.     if opts.receivers and changed:
  191.         recv_list = opts.receivers.split(',')
  192.         subject = "Your USCIS Case %s Status Change Notice " % casenumber
  193.         send_mail("myname@gmail.com", recv_list, subject, report)


  194. if __name__ == '__main__':
  195.     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面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

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