For those who know C#, here is a script:
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace ECAS
{
class Program
{
static Regex RegexHistory = new Regex("\"viewcasehistory\\.do\\?.+\"");
static Regex RegexStatus = new Regex("<li .+?>(.+)<\\/li>");
static async Task Run(string UCI, string Name, string DOB, string COB)
{
var client = new HttpClient();
client.BaseAddress = new Uri("
https://services3.cic.gc.ca/");
client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0");
client.DefaultRequestHeaders.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
client.DefaultRequestHeaders.Add("Referer", "
https://services3.cic.gc.ca/ecas/security.do");
await client.GetStringAsync("/ecas/security.do?lang=en");
await client.PostAsync("/ecas/security.do", new StringContent("lang=&app=&securityInd=agree&_target1=Continue", Encoding.UTF8, "application/x-www-form-urlencoded"));
var status = await client.PostAsync("/ecas/authenticate.do", new StringContent("lang=&_page=_target0&app=&identifierType=1&identifier=" + UCI + "&surname=" + Name + "&dateOfBirth=" + DOB + "&countryOfBirth=" + COB + "&_submit=Continue", Encoding.UTF8, "application/x-www-form-urlencoded"));
foreach (Match match in RegexHistory.Matches(await status.Content.ReadAsStringAsync()))
{
var path = "/ecas/" + WebUtility.HtmlDecode(match.Value.Trim('\"'));
var data = await client.GetStringAsync(path);
data = data.Substring(data.IndexOf("<form"));
data = data.Substring(0, data.IndexOf("</form>"));
data = data.Substring(data.IndexOf("<ol>") + "<ol>".Length);
data = data.Substring(0, data.IndexOf("</ol>"));
data = data.Trim();
foreach (Match m in RegexStatus.Matches(data))
{
Console.WriteLine(m.Groups[1]);
Console.WriteLine();
}
}
}
static void Main(string[] args)
{
var Config = Path.ChangeExtension(System.Reflection.Assembly.GetEntryAssembly().Location, "ini");
if (!File.Exists(Config))
{
using (var file = new StreamWriter(Config))
{
Console.Write("UCI: ");
file.WriteLine(Console.ReadLine());
Console.Write("Surname: ");
file.WriteLine(Console.ReadLine());
Console.Write("Date of birth (YYYY-MM-DD): ");
file.WriteLine(Console.ReadLine());
Console.Write("Country of birth (code): ");
file.WriteLine(Console.ReadLine());
}
}
using (var file = new StreamReader(Config))
{
Run(file.ReadLine(), file.ReadLine(), file.ReadLine(), file.ReadLine()).Wait();
}
Console.Write("Press any key to continue . . .");
Console.ReadKey();
}
}
}