当前位置:编程学习 > C#/ASP.NET >>

asp.net怎么采集入库

如题 --------------------编程问答-------------------- 你是要做数据采集么,联系我,QQ号码:940729677 --------------------编程问答--------------------

   private static string GetPage(string url)
        {
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);

            HttpWebResponse webResponse = null;
            try
            {
                webResponse = (HttpWebResponse)webRequest.GetResponse();
            }
            catch (WebException ex)
            {
                webResponse = (HttpWebResponse)ex.Response;
            }

            Stream stream = webResponse.GetResponseStream();
            StreamReader reader = new StreamReader(stream, System.Text.Encoding.GetEncoding("gb2312"));
            //整个页面内容

            string content = reader.ReadToEnd();
            reader.Close();
            webResponse.Close();
            return content.Replace("<script", " ");
        }
--------------------编程问答-------------------- 1.获取网页源码
2.利用正则获取你想要的内容
3.入库
4.再循环第一步操作
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,