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

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

全局:

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

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

x


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

  7. namespace CheckH1BStatus. Waral dи,
  8. {

  9.     class Program
  10.     {
  11.         private static string USCISUrl = "https://egov.uscis.gov/casestatus/mycasestatus.do?appReceiptNum=WAC{0}";
  12.         private static int receiptNum = 1918552123;  //Case number with out WAC. ----
  13.         private static Regex reg = new Regex(@"(?<=<strong>Your Current Status:</strong>\s+)[^<>]+");. check 1point3acres for more.
  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位

  16.         [STAThread]
  17.         static void Main(string[] args)
  18.         {
  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--). 1point3acres.com
  26.             {
  27.                 int number = receiptNum - i;
  28.                 var url = string.Format(USCISUrl, number);-baidu 1point3acres
  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.                 { . Waral dи,
  35.                     string status = reg.Match(content).Value.Trim();
  36.                     string date = "UnKnown";
  37.                     if (regDate.IsMatch(content))
  38.                     {
  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;
  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;
  61.                         default:
  62.                             Console.BackgroundColor = ConsoleColor.Black;
  63.                             break;
  64.                     }

  65.                     Console.WriteLine(output);
  66.                     Console.BackgroundColor = ConsoleColor.Black;
  67.                 }
  68.                 else
  69.                 {
  70.                     Console.WriteLine(" WAC{0}  ", number);
  71.                 }
    ..
  72.             }

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

  90.                     string output = string.Format(" WAC{0}  -   {1}  -   {2}", number, status, date);
    . From 1point 3acres bbs

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

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

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

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

  138.             Console.ReadKey();
  139.         }
  140.     }

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


.1point3acres
. 1point 3 acres

补充内容 (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面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

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