日期:2014-05-18  浏览次数:20433 次

如何采集信息
做了一个网站,有个股票模块需要采集另一个网站发布的一些信息,就是将一个网站的一些股票大盘的涨停信息采集过来,放在一个table的一些单元格里
请问该如何去做呢?以前没做过采集之类的模块,

------解决方案--------------------
抓他的HTML页面用正则匹配出你需要的信息
C# code

 WebRequest Wrq = WebRequest.Create("你要采集的地址");
                WebResponse Wrs = Wrq.GetResponse();
                Stream strm = Wrs.GetResponseStream();
                StreamReader sr = new StreamReader(strm, System.Text.Encoding.GetEncoding("UTF-8"));
                string allstrm;
                allstrm = sr.ReadToEnd();
                string strPattern = @"相关正则";
                MatchCollection Matches = Regex.Matches(allstrm, strPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);
                foreach (Match NextMatch in Matches)
                {
                    str = NextMatch.Groups["src"].Value.ToString().Trim();
                }

------解决方案--------------------
帮你写了

你看下我写的这个网址

http://topic.csdn.net/u/20081223/09/a7e18f4f-400c-420f-9bd0-7949b87bddf0.html