Пример #1
0
        private void InsertDb(HMDInfo hmdInfo)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>
            {
                ["PubOrganName"]     = hmdInfo.PubOrganName,
                ["ProjectName"]      = hmdInfo.ProjectName,
                ["NatrualName"]      = hmdInfo.NatrualName,
                ["IdentityNumber"]   = hmdInfo.IdentityNumber,
                ["OrganName"]        = hmdInfo.OrganName,
                ["OrganCode"]        = hmdInfo.OrganCode,
                ["PubTime"]          = hmdInfo.PubTime,
                ["PubDeadline"]      = hmdInfo.PubDeadline,
                ["PunishmentNumber"] = hmdInfo.PunishmentNumber,
                ["PunishmentTime"]   = hmdInfo.PunishmentTime,
                ["PunishmentFact"]   = hmdInfo.PunishmentFact,
                ["PunishmentBasis"]  = hmdInfo.PunishmentBasis,
                ["PunishmentResult"] = hmdInfo.PunishmentResult,
                ["ThreadNumber"]     = Thread.CurrentThread.ManagedThreadId.ToString()
            };

            foreach (var info in dic)
            {
                Console.WriteLine($"{info.Key}:{info.Value}");
            }

            _mySqlHelper.InsertTable(dic, "HMDInfo");
        }
Пример #2
0
        private HMDInfo GetInfo(string url)
        {
            Func <string, string> replaceSpace = s => s.Trim().Replace("&nbsp;", "");

            var hmdInfo    = new HMDInfo();
            var httpHelper = new HttpHelper {
                HttpEncoding = _httpEncoding
            };
            var html     = httpHelper.GetHtmlByGet(url);
            var htmlNode = HtmlAgilityPackHelper.GetDocumentNodeByHtml(html);

            hmdInfo.PubOrganName     = replaceSpace(htmlNode.SelectSingleNode("//table[3]//tr[1]/td[2]").InnerText);
            hmdInfo.ProjectName      = replaceSpace(htmlNode.SelectSingleNode("//table[3]//tr[2]/td[2]/nobr").InnerText);
            hmdInfo.NatrualName      = replaceSpace(htmlNode.SelectSingleNode("//table[5]//tr[1]/td[2]").InnerText);
            hmdInfo.IdentityNumber   = replaceSpace(htmlNode.SelectSingleNode("//table[5]//tr[1]/td[4]").InnerText);
            hmdInfo.OrganName        = replaceSpace(htmlNode.SelectSingleNode("//table[5]//tr[2]/td[2]").InnerText);
            hmdInfo.OrganCode        = replaceSpace(htmlNode.SelectSingleNode("//table[5]//tr[3]/td[2]").InnerText);
            hmdInfo.PubTime          = replaceSpace(htmlNode.SelectSingleNode("//table[5]//tr[4]/td[2]").InnerText);
            hmdInfo.PubDeadline      = replaceSpace(htmlNode.SelectSingleNode("//table[5]//tr[4]/td[4]").InnerText);
            hmdInfo.PunishmentNumber = replaceSpace(htmlNode.SelectSingleNode("//table[5]//tr[5]/td[2]").InnerText);
            hmdInfo.PunishmentTime   = replaceSpace(htmlNode.SelectSingleNode("//table[5]//tr[5]/td[4]").InnerText);
            hmdInfo.PunishmentFact   = replaceSpace(htmlNode.SelectSingleNode("//table[5]//tr[6]/td[2]").InnerText);
            hmdInfo.PunishmentBasis  = replaceSpace(htmlNode.SelectSingleNode("//table[5]//tr[7]/td[2]").InnerText);
            hmdInfo.PunishmentResult = replaceSpace(htmlNode.SelectSingleNode("//table[5]//tr[8]/td[2]").InnerText);
            return(hmdInfo);
        }