📣 黑五网一特惠|VIP一年通行证5折,蓝莓、Offer多多同步特惠
查看: 2402| 回复: 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号通过. Χ

漫长的4个半月,总算熬过来了。期间改了个 Python 3 的脚本,定期扫状态,有变更发邮件,算是第一时间收到消息。. Χ
. 1point 3 acres
  1. from pyquery import PyQuery as pq
    . 1point3acres.com
  2. import requests
  3. import smtplib
  4. import os. From 1point 3acres bbs
  5. import sys ..
  6. import os.path
  7. import re
  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-baidu 1point3acres
  13. from optparse import OptionParser
  14. from datetime import datetime, date
  15. . 1point3acres
  16. STATUS_OK = 0
  17. STATUS_ERROR = -1
  18. FILENAME_LASTSTATUS = os.path.join(sys.path[0], "LAST_STATUS_{0}.txt")

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


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

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


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

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

  138.     usage = """
  139.     usage: %prog -c <case_number> [options]
  140.     """
  141.     parser = OptionParser(usage=usage)
  142.     parser.add_option(
  143.         '-c',
  144.         '--casenumber',
  145.         type='string',
  146.         action='store',. check 1point3acres for more.
  147.         dest='casenumber',
  148.         default='YSC1790016391', ..
  149.         help='the USCIS case receipt number you can to query'). 1point3acres
  150.     parser.add_option(
  151.         '-d',
  152.         '--detail',
  153.         action='store_true',.
  154.         dest='detailOn',. 1point3acres
  155.         help="request details about the status returned")
  156.     parser.add_option(
  157.         '--mailto',
  158.         action='store',
  159.         dest='receivers',.1point3acres
  160.         help=(
  161.             "optionally add one or more emails addresses, separated by comma,"
  162.             " to send the notification mail to"))
  163.     opts, args = parser.parse_args()
  164.     casenumber = opts.casenumber
  165.     if not casenumber:
  166.         raise parser.error("No casenumber is provided"). Waral dи,
  167.     # poll status
  168.     code, status, detail = poll_optstatus(casenumber). ----
  169.     if code == STATUS_ERROR:
  170.         print("The case number %s is invalid." % casenumber)
  171.         return. .и
  172.     # report format
  173.     report_format = ("-------  Your USCIS Case [{0}]---------". 1point3acres
  174.                      "\nCurrent Status: [{1}]"
  175.                      "\nDays since received: [{2}]")
  176.     days_elapsed = get_days_since_received(detail)
  177. ..
  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(
  183.         [report, "Previous Status:%s \nChanged: %s" % (laststatus, changed),
  184.          "Current Timestamp: %s " % datetime.now().strftime("%Y-%m-%d %H:%M")])-baidu 1point3acres
  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
  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. .1point3acres

  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
复制代码
. Χ
. check 1point3acres for more.

效果图




评分

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

查看全部评分


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

使用道具 举报

全局:
恭喜恭喜!
回复

使用道具 举报

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

本版积分规则

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