InBlock.gif//此方法获取远程地址的源代码
InBlock.gif        public static string GetHtml(string url)
InBlock.gif        {
InBlock.gif                try
InBlock.gif                {
InBlock.gif                        HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
InBlock.gif                        HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
InBlock.gif                        Stream stream = webResponse.GetResponseStream();
InBlock.gif                        System.IO.StreamReader streamReader = new StreamReader(stream, System.Text.Encoding.GetEncoding("GB2312"));
InBlock.gif                        string content = streamReader.ReadToEnd();
InBlock.gif                        streamReader.Close();
InBlock.gif                        webResponse.Close();
InBlock.gif                        return content.Trim();
InBlock.gif                }
InBlock.gif                catch
InBlock.gif                {
InBlock.gif                        return "-1";
InBlock.gif                }
InBlock.gif
InBlock.gif        }
InBlock.gif//按钮
InBlock.gifprotected void btnRead_Click(object sender, EventArgs e)
InBlock.gif        {
InBlock.gif                string rssURL = txtUrl.Text.Trim();//列表页面url 地址
InBlock.gif                string resultlist = GetHtml(rssURL);//列表页面数据
InBlock.gifReturn(resultlist, int.Parse(TextBox7.Text.ToString()));//调用采集主要方法
InBlock.gif        }
InBlock.gif//主体方法
InBlock.gifprivate string Return(string result, int j)
InBlock.gif        {
InBlock.gif                string strReg = TextBox1.Text.Trim() + @"[(\s\S)]*?" + TextBox2.Text.Trim();//输入新闻列表开始结尾-- /news/2008 ---.shtml
InBlock.gif                Regex re = new Regex(strReg, RegexOptions.IgnoreCase);
InBlock.gif                Match m = re.Match(result);
InBlock.gif                int mn = 0;
InBlock.gif                if (i <= j)
InBlock.gif                {
InBlock.gif                        string NewsString = GetHtml(this.TextBox8.Text.Trim() + m.Value);//查询新闻内容数据
InBlock.gif
InBlock.gif                        string rg_title = TextBox5.Text.Trim() + @"([\s\S]*?)" + TextBox6.Text.Trim();//新闻标题标签
InBlock.gif                        Regex re_title = new Regex(rg_title, RegexOptions.IgnoreCase);
InBlock.gif                        Match m_title = re_title.Match(NewsString);
InBlock.gif                        string n_title = System.Text.RegularExpressions.Regex.Replace(m_title.Value.ToString().Replace("'", ""), "<[^>]+>", "");//新闻标题
InBlock.gif
InBlock.gif                        string rg_note = TextBox3.Text.Trim() + @"([\s\S]*?)" + TextBox4.Text.Trim();//新闻内容标签
InBlock.gif                        Regex re_note = new Regex(rg_note, RegexOptions.IgnoreCase);
InBlock.gif                        Match m_note = re_note.Match(NewsString);
InBlock.gif                        string n_note = m_note.Value.ToString().Replace("'", "");//新闻内容
InBlock.gif                        string selecttitle = "select n_title from zy_News where n_title='" + FunctionLib.StrLib.cutStr(n_title, 48) + "'";
InBlock.gif                        DataSet dstitle = SqlHelp.ExecuteDataSet(SqlHelp.sqlCon, CommandType.Text, selecttitle, null);
InBlock.gif                        if (dstitle.Tables[0].Rows.Count == 0)
InBlock.gif                        {
InBlock.gif                                if (n_note != "" && n_note != null)
InBlock.gif                                {
InBlock.gif                                        string insertsql = "insert into zy_News values(58,0,'" + n_title + "','','','" + n_note + "','','',1,'" + n_title + "','',1,'','',0,0,getdate(),getdate(),0,0,0,0,getdate())";
InBlock.gif
InBlock.gif                                        SqlHelp.ExecuteNonQuery(SqlHelp.sqlCon, CommandType.Text, insertsql, null);
InBlock.gif                                        mn++;
InBlock.gif                                        i++;
InBlock.gif                                }
InBlock.gif                        }
InBlock.gif                        result1 = result.Replace(m.Value, " ");
InBlock.gif                        Return(result1, j);//递归
InBlock.gif                }
InBlock.gif
InBlock.gif        }