📣 黑五网一特惠|VIP一年通行证5折,蓝莓、Offer多多同步特惠
查看: 1638| 回复: 1
跳转到指定楼层
上一主题 下一主题
收起左侧

[H1B] C# 版爬虫,查看前后100 - 1000个case的最新状态

全局:

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

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

x


C#版爬虫, 抓取https://egov.uscis.gov/casestatus/mycasestatus.do上case status各Last update时间,祝各位好运...
.google  и
  1. using System;-baidu 1point3acres
  2. using System.Collections.Generic;
  3. using System.Linq; ..
  4. using System.Text;
  5. using System.Text.RegularExpressions;. 1point 3acres
  6. using System.Threading.Tasks;

  7. namespace CheckH1BStatus
  8. {

  9.     class Program. From 1point 3acres bbs
  10.     {
  11.         private static string USCISUrl = "https://egov.uscis.gov/casestatus/mycasestatus.do?appReceiptNum=WAC{0}";. 1point3acres.com
  12.         private static int receiptNum = 1918552123;  //Case number with out WAC
  13.         private static Regex reg = new Regex(@"(?<=<strong>Your Current Status:</strong>\s+)[^<>]+");
  14.         private static Regex regDate = new Regex("(?is)<strong>Your Current Status:</strong>\\s+([^<>]+).*?<div class=\"rows text-center\">.*?<p>On ([^,]+)");
  15.         private static int Count = 100;  //默认取前后100位. check 1point3acres for more.

  16.         [STAThread]. .и
  17.         static void Main(string[] args)-baidu 1point3acres
  18.         {. 1point3acres
  19.             int received = 0;
  20.             int approved = 0;
  21.             int denied = 0;
  22.             int rfe = 0;
  23.             int total = 0;

  24.             //前100位
  25.             for (int i = Count; i > 0; i--)
  26.             {
  27.                 int number = receiptNum - i;
  28.                 var url = string.Format(USCISUrl, number);
  29.                 System.Net.WebClient client = new System.Net.WebClient();
  30.                 total += 1;
  31.                 var page = client.DownloadData(url);. Χ
  32.                 string content = System.Text.Encoding.UTF8.GetString(page);
  33.                 if (reg.IsMatch(content))
  34.                 { . check 1point3acres for more.
  35.                     string status = reg.Match(content).Value.Trim();
  36.                     string date = "UnKnown";
  37.                     if (regDate.IsMatch(content))
  38.                     {. 1point 3acres
  39.                         date = string.Format("{0}, 2019", regDate.Match(content).Groups[2].Value);
  40.                     }

  41.                     string output = string.Format(" WAC{0}  -   {1}  -   {2}", number, status, date);

  42.                     switch (status)
  43.                     {
  44.                         case CaseStatus.CWR:
  45.                             received += 1;
  46.                             break;
  47.                         case CaseStatus.CWA:
  48.                         case CaseStatus.CWA2:
  49.                             Console.BackgroundColor = ConsoleColor.Green;
  50.                             approved += 1;
  51.                             break;. 1point3acres.com
  52.                         case CaseStatus.RFE:
  53.                         case CaseStatus.RFE2:
  54.                             Console.BackgroundColor = ConsoleColor.Yellow;
  55.                             rfe += 1;
  56.                             break;
  57.                         case CaseStatus.CWD:
  58.                             Console.BackgroundColor = ConsoleColor.Red;
  59.                             denied += 1;
  60.                             break;. 1point3acres
  61.                         default:
  62.                             Console.BackgroundColor = ConsoleColor.Black;
  63.                             break;
  64.                     }. Waral dи,
  65. . ----
  66.                     Console.WriteLine(output);
  67.                     Console.BackgroundColor = ConsoleColor.Black;
  68.                 }
  69.                 else
  70.                 {
  71.                     Console.WriteLine(" WAC{0}  ", number);
  72.                 }
  73.             }.

  74.             //后100位
  75.             for (int i = 0; i <= Count; i++)
  76.             {
  77.                 int number = receiptNum + i;
  78.                 var url = string.Format(USCISUrl, number);
  79.                 System.Net.WebClient client = new System.Net.WebClient();
  80.                 total += 1;-baidu 1point3acres
  81.                 var page = client.DownloadData(url);. 1point 3 acres
  82.                 string content = System.Text.Encoding.UTF8.GetString(page);. ----
  83.                 if (reg.IsMatch(content))
  84.                 {
  85.                     string status = reg.Match(content).Value.Trim();. check 1point3acres for more.
  86.                     string date = "UnKnown";.--
  87.                     if (regDate.IsMatch(content))
  88.                     {
  89.                         date = string.Format("{0}, 2019", regDate.Match(content).Groups[2].Value);-baidu 1point3acres
  90.                     }

  91.                     string output = string.Format(" WAC{0}  -   {1}  -   {2}", number, status, date);

  92.                     if (number == receiptNum)
  93.                     {
  94.                         Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
  95.                     }

  96.                     switch (status). 1point 3acres
  97.                     {
  98.                         case CaseStatus.CWR:
  99.                             received += 1;
  100.                             break;
  101.                         case CaseStatus.CWA:
  102.                         case CaseStatus.CWA2:
  103.                             Console.BackgroundColor = ConsoleColor.Green;
  104.                             approved += 1;
  105.                             break;
  106.                         case CaseStatus.RFE:
  107.                         case CaseStatus.RFE2:
  108.                             Console.BackgroundColor = ConsoleColor.Yellow;. Χ
  109.                             rfe += 1;
  110.                             break;. 1point 3 acres
  111.                         case CaseStatus.CWD:
  112.                             Console.BackgroundColor = ConsoleColor.Red;
  113.                             denied += 1;
  114.                             break;
  115.                         default:
  116.                             Console.BackgroundColor = ConsoleColor.Black;
  117.                             break;
  118.                     }
    . ----

  119.                     Console.WriteLine(output);
  120.                     Console.BackgroundColor = ConsoleColor.Black;
  121.                     if (number == receiptNum). Waral dи,
  122.                     {
  123.                         Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
  124.                     }
  125.                 }
  126.                 else
  127.                 {
  128.                     Console.WriteLine(" WAC{0}  ", number);.
  129.                 }
  130.             }

  131.             Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
  132.             Console.WriteLine("Summary:");
  133.             Console.WriteLine("     Approved:" + approved);. 1point3acres.com
  134.             Console.WriteLine("     Denied:" + denied);
  135.             Console.WriteLine("     RFE:" + rfe);
  136.             Console.WriteLine("     Recived:" + received);
  137.             Console.WriteLine("     Total:" + total);
  138.             Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");

  139.             Console.ReadKey();. 1point3acres.com
  140.         }. Χ
  141.     }

  142.     public class CaseStatus
  143.     {
  144.         public const string CWR = "Case Was Received";
  145.         public const string CWA = "Case Was Approved";
  146.         public const string CWA2 = "Case Was Approved And My Decision Was Emailed";
  147.         public const string RFE = "Request for Additional Evidence Was Sent";. 1point 3acres
  148.         public const string RFE2 = "Response To USCIS' Request For Evidence Was Received";
  149.         public const string RFPP = "Request For Premium Processing Services Was Received";
  150.         public const string CWT = "Case Was Transferred And A New Office Has Jurisdiction";
  151.         public const string CWD = "Decision Notice Mailed";
  152.     }
  153. }
复制代码
. Χ




补充内容 (2019-7-26 14:49):
查看前后case的位数不限,但鉴于被封IP的风险,建议设置在5000内

评分

参与人数 3大米 +5 收起 理由
Taotao666 + 1 给你点个赞!
onajourney + 1 赞一个
ynys + 3 牛!

查看全部评分


上一篇:210号段祈福......
下一篇:今天在线加急之后收到的邮件,这是模板回复吗?
🔗
 楼主| q107770540 2019-7-26 01:48:49 | 只看该作者
全局:

占楼。等了半天终于审核通过
回复

使用道具 举报

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

本版积分规则

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