| 
 | 
 
        private bool GetHttpHtml(string title) 
        { 
            HttpHelper helper = new HttpHelper(); 
            HttpItem item = new HttpItem(); 
            item.URL = @"https://www.baidu.com/s?wd=" + title + "&rsv_spt=1";//请求url 
            item.Method = "get";//请求方式 
            item.ResultType = ResultType.Byte;//返回类型 
            HttpResult result = helper.GetHtml(item);//获取页面内容 
            byte[] bytes = result.ResultByte;  
            Stream stream = new MemoryStream(bytes); 
 
            //将抓取的stream转化为html格式doc 
            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); 
            doc.Load(stream, Encoding.UTF8); 
 
            //doc下取  div节点class="c-abstract" 
            HtmlNodeCollection kwBox = doc.DocumentNode.SelectNodes("//div[@class='c-abstract']"); 
 
            //对比title和抓取结果 
            List<string> emList = new List<string>(); 
            string temp = string.Empty; 
            foreach (HtmlNode hn in kwBox) 
            { 
                temp = HttpHelper.GetBetweenHtml(hn.OuterHtml, "<em>", "</em>"); 
                if (title.Equals(temp)) 
                { 
                    return false; 
                } 
            } 
            return true; 
        } 
 
第一次弄这个东西,求教大家一下。 
具体操作是:数据库有很多数据,根据数据的title,抓取按title百度搜索得到网页的结果,跟结果描述飘红的字体做对比。但是我按数据循环抓取的时候很慢。 
如果数据多的话岂不是要处理很久。 
原数据存的title是db3数据库文件,我打算每个文件开一个线程跑。先试了跑一个文件感觉很慢。半个小时5000条。 
 |   
 
 
 
 |