提取凡客网站内容

        private void button26_Click(object sender, EventArgs e)
        {
//凡客男装频道
            GetHtmlNodeFromLink2("http://www.vancl.com/channel/men.html""UTF-8");//http://www.vancl.com/channel/women.html  children
HtmlAgilityPack.HtmlNodeCollection node = htmlNodes.SelectNodes("//div[@id='listProduct']/ul/li");//"//div[@class='slideBannerA homeSlideAD1']"

            strLink = new string[node.Count];
            strImgSrc = new string[node.Count];
            strTitle = new string[node.Count];
            strMarketPrice = new string[node.Count];
            strCurrentPrice = new string[node.Count];

            int i = 0;
            foreach (HtmlNode htmlNode in node)
            {
                try
                {
                    strLink[i] = htmlNode.ChildNodes[0].Attributes["href"].Value;
                    strImgSrc[i] = htmlNode.ChildNodes[0].ChildNodes[0].Attributes["src"] == null ? htmlNode.ChildNodes[0].ChildNodes[0].Attributes["original"].Value : htmlNode.ChildNodes[0].ChildNodes[0].Attributes["src"].Value; ;
                    strTitle[i] = htmlNode.ChildNodes[1].Attributes["title"].Value;
                    strMarketPrice[i] = htmlNode.ChildNodes[3].ChildNodes[1].InnerHtml.Trim().Replace("""").Replace("¥""");
                    strCurrentPrice[i++] = htmlNode.ChildNodes[3].ChildNodes[4].InnerHtml.Trim().Replace("¥""");
                }
                catch
                { }
            }
        }

        private void button27_Click(object sender, EventArgs e)
        {
            //运动装
            GetHtmlNodeFromLink2("http://sports.vancl.com/""UTF-8");//http://www.vancl.com/channel/women.html  children
            HtmlAgilityPack.HtmlNodeCollection node = htmlNodes.SelectNodes("//ul[@class='common-box-right']/li");//"//div[@class='slideBannerA homeSlideAD1']"

            strLink = new string[node.Count];
            strImgSrc = new string[node.Count];
            strTitle = new string[node.Count];
            strMarketPrice = new string[node.Count];
            strCurrentPrice = new string[node.Count];

            int i = 0;
            foreach (HtmlNode htmlNode in node)
            {
                try
                {
                    strLink[i] = htmlNode.ChildNodes[1].ChildNodes[0].Attributes["href"].Value;
                    strImgSrc[i] = htmlNode.ChildNodes[1].ChildNodes[0].ChildNodes[0].Attributes["src"].Value;// == null ? htmlNode.ChildNodes[0].ChildNodes[0].Attributes["original"].Value : htmlNode.ChildNodes[0].ChildNodes[0].Attributes["src"].Value; ;
                    strTitle[i] = htmlNode.ChildNodes[1].ChildNodes[0].ChildNodes[0].Attributes["alt"].Value;
                    strMarketPrice[i] = htmlNode.ChildNodes[5].ChildNodes[0].ChildNodes[1].ChildNodes[0].InnerHtml.Trim().Replace("""").Replace("¥""");
                    strCurrentPrice[i++] = htmlNode.ChildNodes[5].ChildNodes[2].InnerHtml.Trim().Replace("售价¥""");
                }
                catch
                { }
            }

        }

        private void button28_Click(object sender, EventArgs e)
        { 
            //运动鞋
            GetHtmlNodeFromLink2("http://sports.vancl.com/""UTF-8");//http://www.vancl.com/channel/women.html  children
        HtmlAgilityPack.HtmlNodeCollection node = htmlNodes.SelectNodes("//ul[@class='common-boxul']/li");//"//div[@class='slideBannerA homeSlideAD1']"

            strLink = new string[node.Count];
            strImgSrc = new string[node.Count];
            strTitle = new string[node.Count];
            strMarketPrice = new string[node.Count];
            strCurrentPrice = new string[node.Count];

            int i = 0;
            foreach (HtmlNode htmlNode in node)
            {
                try
                {
                    strLink[i] = htmlNode.ChildNodes[1].ChildNodes[0].Attributes["href"].Value;
                    strImgSrc[i] = htmlNode.ChildNodes[1].ChildNodes[0].ChildNodes[0].Attributes["src"].Value;// == null ? htmlNode.ChildNodes[0].ChildNodes[0].Attributes["original"].Value : htmlNode.ChildNodes[0].ChildNodes[0].Attributes["src"].Value; ;
                    strTitle[i] = htmlNode.ChildNodes[1].ChildNodes[0].ChildNodes[0].Attributes["alt"].Value;
                    strMarketPrice[i] = htmlNode.ChildNodes[5].ChildNodes[0].ChildNodes[1].ChildNodes[0].InnerHtml.Trim().Replace("""").Replace("¥""");
                    strCurrentPrice[i++] = htmlNode.ChildNodes[5].ChildNodes[2].InnerHtml.Trim().Replace("售价¥""");
                }
                catch
                { }
            }

        }

        private void button29_Click(object sender, EventArgs e)
        {
            //本周热销运动装
 GetHtmlNodeFromLink2("http://sports.vancl.com/""UTF-8");//http://www.vancl.com/channel/women.html  children
 HtmlAgilityPack.HtmlNodeCollection node = htmlNodes.SelectNodes("//div[@class='common-box clearfix h514']/ul");//"//div[@class='slideBannerA homeSlideAD1']"

            strLink = new string[node.Count];
            strImgSrc = new string[node.Count];
            strTitle = new string[node.Count];
            strMarketPrice = new string[node.Count];
            strCurrentPrice = new string[node.Count];

            int i = 0;
            foreach (HtmlNode htmlNode in node)
            {
                try
                {
                    strLink[i] = htmlNode.ChildNodes[3].ChildNodes[0].Attributes["href"].Value;
                    strImgSrc[i] = htmlNode.ChildNodes[3].ChildNodes[0].ChildNodes[0].Attributes["src"].Value;// == null ? htmlNode.ChildNodes[0].ChildNodes[0].Attributes["original"].Value : htmlNode.ChildNodes[0].ChildNodes[0].Attributes["src"].Value; ;
                    strTitle[i] = htmlNode.ChildNodes[3].ChildNodes[0].ChildNodes[0].Attributes["alt"].Value;
                    //strMarketPrice[i] = htmlNode.ChildNodes[3].ChildNodes[3].InnerHtml.Trim().Replace("¥", "").Replace("¥", "");
                    strCurrentPrice[i++] = htmlNode.ChildNodes[5].ChildNodes[5].InnerHtml.Trim().Replace("""");
                }
                catch
                { }
            }
        }

        private void button30_Click(object sender, EventArgs e)
        { 
            
            //运动装广告
            GetHtmlNodeFromLink2("http://sports.vancl.com/""UTF-8");//http://www.vancl.com/channel/women.html  children
        HtmlAgilityPack.HtmlNodeCollection node = htmlNodes.SelectNodes("//div[@class='common-box-left']/a");//"//div[@class='slideBannerA homeSlideAD1']"

            strLink = new string[node.Count];
            strImgSrc = new string[node.Count];
            strTitle = new string[node.Count];
            strMarketPrice = new string[node.Count];
            strCurrentPrice = new string[node.Count];

            int i = 0;
            foreach (HtmlNode htmlNode in node)
            {
                try
                {
                    strLink[i] = htmlNode.Attributes["href"].Value;
                    strImgSrc[i++] = htmlNode.ChildNodes[0].Attributes["src"].Value;// == null ? htmlNode.ChildNodes[0].ChildNodes[0].Attributes["original"].Value : htmlNode.ChildNodes[0].ChildNodes[0].Attributes["src"].Value; ;
                    
//strTitle[i] = htmlNode.ChildNodes[3].ChildNodes[0].ChildNodes[0].Attributes["alt"].Value;
                    
//strMarketPrice[i] = htmlNode.ChildNodes[3].ChildNodes[3].InnerHtml.Trim().Replace("¥", "").Replace("¥", "");
                    
//strCurrentPrice[i++] = htmlNode.ChildNodes[5].ChildNodes[5].InnerHtml.Trim().Replace("¥", "");
                }
                catch
                { }
            }

        }

2011-11-14
        private void button36_Click(object sender, EventArgs e)
        {
            //聚划算服饰
            
//GetHtmlNodeFromLink3("http://ju.taobao.com/tg/today_items.htm?frontCatId=1000");//, "UTF-8");//http://www.vancl.com/channel/women.html  children
            
//聚划算时尚
            GetHtmlNodeFromLink3("http://ju.taobao.com/tg/today_items.htm?frontCatId=2000");
            //聚划算鞋包
            GetHtmlNodeFromLink3("http://ju.taobao.com/tg/today_items.htm?frontCatId=3000");
            //聚划算母婴
            GetHtmlNodeFromLink3("http://ju.taobao.com/tg/today_items.htm?frontCatId=6000");
            //聚划算居家
            GetHtmlNodeFromLink3("http://ju.taobao.com/tg/today_items.htm?frontCatId=7000");
            HtmlAgilityPack.HtmlNodeCollection node = htmlNodes.SelectNodes("//div[@class='more-group']/ul/li/div");//"//div[@class='slideBannerA homeSlideAD1']"
//
            strLink = new string[node.Count];
            strImgSrc = new string[node.Count];
            strTitle = new string[node.Count];
            strMarketPrice = new string[node.Count];
            strCurrentPrice = new string[node.Count];

            int i = 0;
            foreach (HtmlNode htmlNode in node)
            {
                try
                {
                    strLink[i] = htmlNode.ChildNodes[1].ChildNodes[0].Attributes["href"].Value;
                    strImgSrc[i] = htmlNode.ChildNodes[3].ChildNodes[1].ChildNodes[0].Attributes["src"] == null ? htmlNode.ChildNodes[3].ChildNodes[1].ChildNodes[0].Attributes["data-ks-lazyload"].Value : htmlNode.ChildNodes[3].ChildNodes[1].ChildNodes[0].Attributes["src"].Value; ;
                    string str=htmlNode.ChildNodes[1].ChildNodes[0].Attributes["title"].Value;
                    strTitle[i] = str.Substring(str.IndexOf("")+1);
                    strMarketPrice[i] = htmlNode.ChildNodes[7].ChildNodes[1].ChildNodes[1].InnerHtml.Trim().Replace("""").Replace("¥""").Replace("""");
                    strCurrentPrice[i++] = htmlNode.ChildNodes[9].ChildNodes[1].ChildNodes[1].InnerHtml.Trim().Replace("乐蜂价:¥""");
                }
                catch
                { }
            }

        }

        private void button37_Click(object sender, EventArgs e)
        {
            //Vjia 限时抢购
            GetHtmlNodeFromLink2("http://www.vjia.com/Active/RushToBuy.aspx""UTF-8");
            HtmlAgilityPack.HtmlNodeCollection node = htmlNodes.SelectNodes("//div[@class='Mid']/div[@class='M_left' or @class='M_right']");//"//div[@class='slideBannerA homeSlideAD1']"
//
            strLink = new string[node.Count+1];
            strImgSrc = new string[node.Count + 1];
            strTitle = new string[node.Count + 1];
            strMarketPrice = new string[node.Count + 1];
            strCurrentPrice = new string[node.Count + 1];

            int i = 0;
            //Vjia 限时抢购-力推
            HtmlAgilityPack.HtmlNode otherNode = htmlNodes.SelectSingleNode("//div[@class='Pro_01']");//"//div[@class='slideBannerA homeSlideAD1']"
            strLink[i] = otherNode.ChildNodes[0].Attributes["href"].Value;
            strImgSrc[i] = otherNode.ChildNodes[0].ChildNodes[1].Attributes["src"].Value;// == null ? htmlNode.ChildNodes[3].ChildNodes[1].ChildNodes[0].Attributes["data-ks-lazyload"].Value : htmlNode.ChildNodes[3].ChildNodes[1].ChildNodes[0].Attributes["src"].Value; ;
            
//string str=htmlNode.ChildNodes[1].ChildNodes[0].Attributes["title"].Value;
            strTitle[i] = otherNode.ChildNodes[1].ChildNodes[0].ChildNodes[0].InnerHtml.Trim(); //str.Substring(str.IndexOf("】") + 1);
            strMarketPrice[i] = otherNode.ChildNodes[1].ChildNodes[2].ChildNodes[2].InnerHtml.Trim().Replace("""").Replace("¥""").Replace("""");
            strCurrentPrice[i++] = otherNode.ChildNodes[1].ChildNodes[4].ChildNodes[3].InnerHtml.Trim().Replace("乐蜂价:¥""");
                


            foreach (HtmlNode htmlNode in node)
            {
                try
                {
                    strLink[i] = htmlNode.ChildNodes[0].ChildNodes[1].Attributes["href"].Value;
                    strImgSrc[i] = htmlNode.ChildNodes[0].ChildNodes[1].ChildNodes[1].Attributes["src"].Value;// == null ? htmlNode.ChildNodes[3].ChildNodes[1].ChildNodes[0].Attributes["data-ks-lazyload"].Value : htmlNode.ChildNodes[3].ChildNodes[1].ChildNodes[0].Attributes["src"].Value; ;
                    
//string str=htmlNode.ChildNodes[1].ChildNodes[0].Attributes["title"].Value;
                    strTitle[i] = htmlNode.ChildNodes[0].ChildNodes[3].ChildNodes[1].ChildNodes[0].InnerHtml.Trim(); //str.Substring(str.IndexOf("】") + 1);
                    strMarketPrice[i] = htmlNode.ChildNodes[1].ChildNodes[3].InnerHtml.Trim().Replace("""").Replace("¥""").Replace("""");
                    strCurrentPrice[i++] = htmlNode.ChildNodes[1].ChildNodes[12].InnerHtml.Trim().Replace("乐蜂价:¥""");
                }
                catch
                { }
            }
        }

        private void button38_Click(object sender, EventArgs e)
        {
            //最新到货 全部
            
//GetHtmlNodeFromLink2("http://s.vancl.com/search?k=", "UTF-8");//不怎么好用
            
//最新男装   40条记录
           
// GetHtmlNodeFromLink2("http://s.vancl.com/1667.html", "UTF-8");
           
//配饰
            
//GetHtmlNodeFromLink2("http://s.vancl.com/1278.html", "UTF-8");
           
//饰品
            
//GetHtmlNodeFromLink2("http://s.vancl.com/4009.html", "UTF-8");
            
//饰品
            
//GetHtmlNodeFromLink2("http://s.vancl.com/4692.html", "UTF-8");
            
//童装
            
//GetHtmlNodeFromLink2("http://s.vancl.com/1516.html", "UTF-8");
            
//创意生活
            
//GetHtmlNodeFromLink2("http://s.vancl.com/3316.html", "UTF-8");
            
// 鞋
            
//GetHtmlNodeFromLink2("http://s.vancl.com/1292.html", "UTF-8");
            
// 化妆品
             
//GetHtmlNodeFromLink2("http://s.vancl.com/2986.html", "UTF-8");
            
// 运动
             GetHtmlNodeFromLink2("http://s.vancl.com/2927.html""UTF-8");
            HtmlAgilityPack.HtmlNodeCollection node = htmlNodes.SelectNodes("//div[@class='pruarea']/ul/li");//"//div[@class='slideBannerA homeSlideAD1']"

            strLink = new string[node.Count];
            strImgSrc = new string[node.Count];
            strTitle = new string[node.Count];
            strMarketPrice = new string[node.Count];
            strCurrentPrice = new string[node.Count];

            int i = 0;
            foreach (HtmlNode htmlNode in node)
            {
                try
                {
                    if (htmlNode.ChildNodes[1].ChildNodes[1].Attributes["href"] == null)
                    {
                        strLink[i] = htmlNode.ChildNodes[1].ChildNodes[3].Attributes["href"].Value;
                        strImgSrc[i] = htmlNode.ChildNodes[1].ChildNodes[3].ChildNodes[1].Attributes["src"] == null ? htmlNode.ChildNodes[1].ChildNodes[3].ChildNodes[1].Attributes["original"].Value : htmlNode.ChildNodes[1].ChildNodes[3].ChildNodes[1].Attributes["src"].Value; ;
                        //string str = htmlNode.ChildNodes[1].ChildNodes[1].ChildNodes[0].Attributes["alt"].Value;
                        strTitle[i] = htmlNode.ChildNodes[1].ChildNodes[3].ChildNodes[1].Attributes["alt"].Value;
                    }
                    else
                    {
                        strLink[i] = htmlNode.ChildNodes[1].ChildNodes[1].Attributes["href"].Value;
                        strImgSrc[i] = htmlNode.ChildNodes[1].ChildNodes[1].ChildNodes[1].Attributes["src"] == null ? htmlNode.ChildNodes[1].ChildNodes[1].ChildNodes[1].Attributes["original"].Value : htmlNode.ChildNodes[1].ChildNodes[1].ChildNodes[1].Attributes["src"].Value; ;
                        //string str = htmlNode.ChildNodes[1].ChildNodes[1].ChildNodes[0].Attributes["alt"].Value;
                        strTitle[i] = htmlNode.ChildNodes[1].ChildNodes[1].ChildNodes[1].Attributes["alt"].Value;
                    }
                    strMarketPrice[i] = htmlNode.ChildNodes[5].ChildNodes[1].ChildNodes[1].InnerHtml.Trim().Replace("""").Replace("¥""").Replace("""");
                    strCurrentPrice[i++] = htmlNode.ChildNodes[5].ChildNodes[2].InnerHtml.Replace("售价¥""").Replace("<strong>""").Replace("</strong>""").Trim();
                }
                catch
                { }
            }
        }

        private void button39_Click(object sender, EventArgs e)
        {
            //女装
            GetHtmlNodeFromLink2("http://s.vancl.com/1571.html""UTF-8");

            HtmlAgilityPack.HtmlNodeCollection node = htmlNodes.SelectNodes("//div[@class='pruarea2']/ul/li");//"//div[@class='slideBannerA homeSlideAD1']"
            
//
            strLink = new string[node.Count];
            strImgSrc = new string[node.Count];
            strTitle = new string[node.Count];
            strMarketPrice = new string[node.Count];
            strCurrentPrice = new string[node.Count];

            int i = 0;
            foreach (HtmlNode htmlNode in node)
            {
                try
                {
                    if (htmlNode.ChildNodes[3].ChildNodes[1].Attributes["href"] == null)
                    {
                        strLink[i] = htmlNode.ChildNodes[3].ChildNodes[3].Attributes["href"].Value;
                        strImgSrc[i] = htmlNode.ChildNodes[3].ChildNodes[3].ChildNodes[1].Attributes["src"] == null ? htmlNode.ChildNodes[3].ChildNodes[3].ChildNodes[1].Attributes["original"].Value : htmlNode.ChildNodes[3].ChildNodes[3].ChildNodes[1].Attributes["src"].Value; ;
                        //string str = htmlNode.ChildNodes[1].ChildNodes[1].ChildNodes[0].Attributes["alt"].Value;
                        strTitle[i] = htmlNode.ChildNodes[3].ChildNodes[3].ChildNodes[1].Attributes["alt"].Value;
                    }
                    else
                    {
                        strLink[i] = htmlNode.ChildNodes[3].ChildNodes[1].Attributes["href"].Value;// == null ? htmlNode.ChildNodes[3].ChildNodes[3].Attributes["href"].Value : htmlNode.ChildNodes[3].ChildNodes[1].Attributes["href"].Value;
                        strImgSrc[i] = htmlNode.ChildNodes[3].ChildNodes[1].ChildNodes[1].Attributes["src"] == null ? htmlNode.ChildNodes[3].ChildNodes[1].ChildNodes[1].Attributes["original"].Value : htmlNode.ChildNodes[3].ChildNodes[1].ChildNodes[1].Attributes["src"].Value; ;
                        //string str = htmlNode.ChildNodes[1].ChildNodes[1].ChildNodes[0].Attributes["alt"].Value;
                        strTitle[i] = htmlNode.ChildNodes[3].ChildNodes[1].ChildNodes[1].Attributes["alt"].Value;
                    }
                    strMarketPrice[i] = htmlNode.ChildNodes[9].ChildNodes[1].ChildNodes[1].InnerHtml.Trim().Replace("""").Replace("¥""").Replace("""");
                   string str = htmlNode.ChildNodes[9].ChildNodes[3].ChildNodes[0].InnerHtml.Replace("售价¥""").Replace("<strong>""").Replace("</strong>""").Trim();
                   if (string.IsNullOrEmpty(str))
                       strCurrentPrice[i++] = htmlNode.ChildNodes[9].ChildNodes[3].ChildNodes[1].InnerHtml.Replace("售价¥""").Replace("<strong>""").Replace("</strong>""").Trim();
                   else
                       strCurrentPrice[i++] = str;
                }
                catch
                { }
            }

        }
posted @ 2011-11-09 17:51  Care健康  阅读(362)  评论(2编辑  收藏  举报
版权
作者:Bober Song

出处:http://bober.cnblogs.com

Care健康:http://www.aicareyou.com

推荐空间:华夏名网

本文首发博客园,版权归作者跟博客园共有。

转载必须保留本段声明,并在页面显著位置给出本文链接,否则保留追究法律责任的权利。