void info_SJ_更新公告(object sender, Even_更新公告 e) { string tim = DateTime.Now.ToString(); if (e.type == "便民公告") { label12.Text = "便民公告 [" + tim + "]:" + e.title; } if (e.type == "政府公告") { label13.Text = "政府公告 [" + tim + "]:" + e.title; } }
private void update_公告(string url_index, string type) { string patt1 = "<div class=\"lanmulist\">[\\s\\S]*</ul>";//取 表格内容 正则表达式 string nry = HTMLHelper.Get_Http_utf8(url_index);//取首页内容 Regex reg = new Regex(patt1); string nrtab = reg.Match(nry).Value;//获取 表格内容 Regex regtr = new Regex("<a.*</a>"); MatchCollection matchTR = regtr.Matches(nrtab); //取得行集合 Regex titleR = new Regex(">.*</a>"); string temp = ""; if (type == "政府公告") { temp = "zfgg"; } if (type == "便民公告") { temp = "bmgg"; } Regex urlR = new Regex("Item.*aspx"); int n = 0; Even_更新公告 e = new Even_更新公告(); for (int i = 0; i < matchTR.Count; i++) { n = n + 1; string title = titleR.Match(matchTR[i].Value).Value; string url = "http://www.luzhou.gov.cn/" + urlR.Match(matchTR[i].Value).Value; title = title.Substring(1, title.Length - 5); e.title = title; e.type = type; //Sys.DebugMes(matchTR[i].Value); //Sys.DebugMes(title + "||" + url); update_sql(title, url, n, type); if (this.SJ_更新公告 != null)//触发事件 { this.SJ_更新公告(this, e); } if (n > 10) { break; } } }