/// <summary> /// 获取快递公司列表 /// </summary> private static void ParseExpressCode() { string HTML = GetHTML("http://m.kuaidi100.com/all/", "61.234.249.107:8118"); var doc = new HtmlDocument(); doc.LoadHtml(HTML); var coms = doc.DocumentNode.SelectNodes(@"//dl[@id='comList']/dd/a"); List<ExpressCom> list = new List<ExpressCom>(); HtmlAttribute atr = null; foreach (var node in coms) { ExpressCom item = new ExpressCom(); atr = node.Attributes["data-code"]; if (atr != null) { item.CompanyCode = atr.Value.Trim(); } item.CompanyName = node.InnerText.Trim(); list.Add(item); } if (list.Count > 0) { SQLHelper.ExecuteNonQuery("Truncate TABLE p_ExpressCompany"); SQLHelper.BatchSaveData(list, "p_ExpressCompany"); } }
/// <summary> /// 获取快递公司列表 /// </summary> private static void ParseExpressCode() { string HTML = GetHTML("http://m.kuaidi100.com/all/", "61.234.249.107:8118"); var doc = new HtmlDocument(); doc.LoadHtml(HTML); var coms = doc.DocumentNode.SelectNodes(@"//dl[@id='comList']/dd/a"); List <ExpressCom> list = new List <ExpressCom>(); HtmlAttribute atr = null; foreach (var node in coms) { ExpressCom item = new ExpressCom(); atr = node.Attributes["data-code"]; if (atr != null) { item.CompanyCode = atr.Value.Trim(); } item.CompanyName = node.InnerText.Trim(); list.Add(item); } if (list.Count > 0) { SQLHelper.ExecuteNonQuery("Truncate TABLE p_ExpressCompany"); SQLHelper.BatchSaveData(list, "p_ExpressCompany"); } }