예제 #1
0
        public List <Company> GetCompanies()
        {
            List <Company> companyList = new List <Company> ();
            RestClient     client      = new RestClient(@"http://internship.iitm.ac.in/students/comp_list.php");
            RestRequest    request     = new RestRequest(Method.GET);

            request.AddCookie(cookie.Name, cookie.Value);
            IRestResponse response = client.Execute(request);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                return(new List <Company> ());
            }
            string cleanHtml = CleanHtml(response.Content);

            //Parse table into Company objects
            HtmlDocument htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(cleanHtml);
            HtmlNode companyTable = htmlDoc.DocumentNode.SelectNodes("//table") [3];

            ConArt.Out("Starting data collection...");
            //Select rows and parse data within
            HtmlNodeCollection rowsList = companyTable.SelectNodes("tr");

            for (int i = 1; i < rowsList.Count; ++i)
            {
                HtmlNodeCollection columnList = rowsList [i].SelectNodes("td");
                Company            company    = new Company();
                company.Name    = columnList [1].InnerText.Replace("\n", "");
                company.Profile = columnList [2].InnerText;
                string profileAddress = columnList [2].SelectSingleNode("a").GetAttributeValue("href", "");
                company.DetailUri = new Uri("http://internship.iitm.ac.in/students/" + HttpUtility.HtmlDecode(profileAddress), UriKind.Absolute);
                DateTime.TryParse(columnList [3].InnerText, out company.TalkDate);
                DateTime.TryParse(columnList [4].InnerText, out company.ResumeDeadline);
                DateTime.TryParse(columnList [5].InnerText, out company.TestDate);
                DateTime.TryParse(columnList [6].InnerText, out company.GdDate);
                DateTime.TryParse(columnList [7].InnerText, out company.TalkDate);
                company.Status        = Parsers.ParseStatus(columnList [7].InnerText);
                company.DetailSnippet = GetCompanyDetails(company);
                companyList.Add(company);

                //Update progress bar
                Console.CursorLeft = 0;
                Console.Write((int)i * 100 / rowsList.Count + "% Complete");
            }
            Console.CursorLeft = 0;
            Console.WriteLine("                 ");

            return(companyList);
        }
예제 #2
0
 public LibIntern()
 {
     char[] rollno, password;
     ConArt.Ask("Roll no. ");
     rollno = getSecureText();
     ConArt.Ask("Password ");
     password = getSecureText();
     if (!Login(ref rollno, ref password))
     {
         ConArt.Out("Cannot Login", MessageType.Error);
         Environment.Exit(-1);
     }
     ConArt.Out("Logged in");
     TotalCompanies = GetCompanies();
 }
예제 #3
0
        public static void Main(string[] args)
        {
            //args matching
            string regexPattern;

            if (args.Length > 0)
            {
                regexPattern = args.First();
            }
            else
            {
                regexPattern = @"Dual Degree.+(All|Mech)";
            }

            LibIntern      intern    = new LibIntern();
            List <Company> companies = intern.TotalCompanies;

            //Applied companies list
            ConArt.Out("Applied Companies");
            Company[] appliedCompanies = companies.Where(a => a.Status == RegisterStatus.Applied).ToArray();
            if (appliedCompanies.Length > 0)
            {
                for (int i = 0; i < appliedCompanies.Length; ++i)
                {
                    Console.WriteLine(appliedCompanies [i].Name);
                }
            }
            else
            {
                ConArt.Out("You have applied for no company", MessageType.Warning);
            }

            Console.WriteLine();
            //Open for Mech
            ConArt.Out("Open Companies for Mech Duals");
            Company[] openCompanies = intern.GetOpenCompanies(regexPattern).Where(x => x.Status != RegisterStatus.Applied && x.Status != RegisterStatus.Closed).ToArray();
            if (openCompanies.Length > 0)
            {
                for (int i = 0; i < openCompanies.Length; ++i)
                {
                    Console.WriteLine(openCompanies [i].Name + " - Rs." + intern.ParseSalary(openCompanies[i].DetailSnippet));
                }
            }
            else
            {
                ConArt.Out("No open company found", MessageType.Warning);
            }

            Console.WriteLine();
            //Open for applications
            ConArt.Out("Companies accepting registrations");
            Company[] regOpenCompanies = companies.Where(a => a.Status == RegisterStatus.Open).ToArray();
            if (regOpenCompanies.Length > 0)
            {
                for (int i = 0; i < regOpenCompanies.Length; ++i)
                {
                    Console.WriteLine(regOpenCompanies [i].Name);
                }
            }
            else
            {
                ConArt.Out("No company accepts registration now", MessageType.Warning);
            }
        }