日期:2014-05-18 浏览次数:20959 次
MSXML2.XMLHTTP xmlhttp = new MSXML2.XMLHTTPClass();
        
        for (int i = 0; i < url.Count; i++)
        {
            xmlhttp.open("POST", url[i].Site+webaddre, true, null, null);
            //xmlhttp.setRequestHeader("Content-Type", "text/xml;charset=gb2312");
            xmlhttp.send(null);
            Num num = null;
            if (xmlhttp.readyState == 4)
            {
                string str = string.Empty;
                if (url[i].Name == "百度")
                    str = Encoding.Default.GetString((byte[])xmlhttp.responseBody);
                else
                    str = xmlhttp.responseText;
                MatchCollection maction = Regex.Matches(str, url[i].Patter);
                
                if(maction[0].Value != null)
                    num = new Num(url[i].Name,maction[0].Value,"0");
                else
                    num = new Num(url[i].Name, "没抓到", "0");
                cont.Add(num); 
            }
            else
            {
                num = new Num(url[i].Name, "抓取超时","0");
                cont.Add(num);
                //return;
            }