• 提取网站内容


                //http://www.vivian.cn/    优惠图片
                  HtmlAgilityPack.HtmlNode nodes = GetHtmlNodeFromLink("http://www.vivian.cn/""UTF-8");
                  HtmlAgilityPack.HtmlNodeCollection node = nodes.SelectNodes("//div[@class='index_pl4Img' or @class='index_pl5Img' or @class='index_pl6Img' or @class='index_pl7Img' or @class='index_pl8Img' or @class='index_pl9Img']/a");//"//div[@class='slideBannerA homeSlideAD1']"

                string[] strLink = new string[node.Count];
                string[] strImg = new string[node.Count];
                string[] strAlt = new string[node.Count];
                string[] strPrice = new string[node.Count];
                string[] strCurrentPrice = new string[node.Count];

                int i = 0;
                foreach (HtmlNode htmlNode in node)
                {
                    try
                    {
                        strLink[i] = htmlNode.Attributes["href"].Value;
                       // strAlt[i] = htmlNode.ChildNodes[1].ChildNodes[1].ChildNodes[0].Attributes["title"].Value;
                        strImg[i++] = htmlNode.ChildNodes[0].Attributes["src"].Value;
                        //strPrice[i] = htmlNode.ChildNodes[6].ChildNodes[1].ChildNodes[1].InnerHtml.Trim().Replace("¥", "");
                        
    //strCurrentPrice[i++] = htmlNode.ChildNodes[1].ChildNodes[3].ChildNodes[3].ChildNodes[0].ChildNodes[1].InnerHtml.Trim().Replace("¥", "");
                    }
                    catch 
                    { }
                }
            private void button12_Click(object sender, EventArgs e)
            {
                //http://www.pb89.com/   图片广告
                HtmlAgilityPack.HtmlNode nodes = GetHtmlNodeFromLink("http://www.pb89.com/""UTF-8");
                HtmlAgilityPack.HtmlNodeCollection node = nodes.SelectNodes("//div[@class='p_ads']/div[@class='p_ads_left' or @class='p_ads_right']/a");//"//div[@class='slideBannerA homeSlideAD1']"

                string[] strLink = new string[node.Count];
                string[] strImg = new string[node.Count];
                string[] strAlt = new string[node.Count];
                string[] strPrice = new string[node.Count];
                string[] strCurrentPrice = new string[node.Count];

                int i = 0;
                foreach (HtmlNode htmlNode in node)
                {
                    try
                    {
                        strLink[i] = htmlNode.Attributes["href"].Value;
                        strAlt[i] = htmlNode.ChildNodes[0].Attributes["alt"].Value;
                        strImg[i++] = htmlNode.ChildNodes[0].Attributes["src"].Value;
                        //strPrice[i] = htmlNode.ChildNodes[6].ChildNodes[1].ChildNodes[1].InnerHtml.Trim().Replace("¥", "");
                        
    //strCurrentPrice[i++] = htmlNode.ChildNodes[1].ChildNodes[3].ChildNodes[3].ChildNodes[0].ChildNodes[1].InnerHtml.Trim().Replace("¥", "");
                    }
                    catch
                    { }
                }

            }

            private void button13_Click(object sender, EventArgs e)
            {

                //http://www.pb89.com/   产品列表
                HtmlAgilityPack.HtmlNode nodes = GetHtmlNodeFromLink("http://www.pb89.com/""UTF-8");
                HtmlAgilityPack.HtmlNodeCollection node = nodes.SelectNodes("//div[@class='p_list']/ul/li");//"//div[@class='slideBannerA homeSlideAD1']"

                string[] strLink = new string[node.Count];
                string[] strImg = new string[node.Count];
                string[] strAlt = new string[node.Count];
                string[] strPrice = new string[node.Count];
                string[] strCurrentPrice = new string[node.Count];

                int i = 0;
                foreach (HtmlNode htmlNode in node)
                {
                    try
                    {
                        strLink[i] = "http://www.pb89.com/" + htmlNode.ChildNodes[0].Attributes["href"].Value;
                        strImg[i] = htmlNode.ChildNodes[0].ChildNodes[1].Attributes["src"].Value;
                        strAlt[i] = htmlNode.ChildNodes[2].ChildNodes[0].ChildNodes[0].InnerHtml.Trim();
                        strPrice[i] = htmlNode.ChildNodes[4].ChildNodes[0].InnerHtml.Trim().Replace("""");
                        strCurrentPrice[i++] = htmlNode.ChildNodes[4].ChildNodes[2].InnerHtml.Trim().Replace("""");
                    }
                    catch
                    { }
                }
            }
                //http://search.yihaodian.com/s/c19558   女装产品列表
                HtmlAgilityPack.HtmlNode nodes = GetHtmlNodeFromLink("http://search.yihaodian.com/s/c19558""UTF-8");
                HtmlAgilityPack.HtmlNodeCollection node = nodes.SelectNodes("//div[@class='producteg fl']");//"//div[@class='slideBannerA homeSlideAD1']"

                string[] strLink = new string[node.Count];
                string[] strImg = new string[node.Count];
                string[] strAlt = new string[node.Count];
                string[] strPrice = new string[node.Count];
                string[] strCurrentPrice = new string[node.Count];

                int i = 0;
                foreach (HtmlNode htmlNode in node)
                {
                    try
                    {
                        strLink[i] = htmlNode.ChildNodes[3].ChildNodes[1].Attributes["href"].Value;
                        strImg[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;
                        strAlt[i] = htmlNode.ChildNodes[3].ChildNodes[1].ChildNodes[1].Attributes["title"].Value;
                        strPrice[i] = htmlNode.ChildNodes[7].ChildNodes[1].InnerHtml.Trim().Replace("""");
                        strCurrentPrice[i++] = htmlNode.ChildNodes[7].ChildNodes[3].InnerHtml.Trim().Replace("¥""");
                    }
                    catch
                    { }
                }
            private void button16_Click(object sender, EventArgs e)
            {

                //http://www.masamaso.com/  gallery ad
                HtmlAgilityPack.HtmlNode nodes = GetHtmlNodeFromLink("http://www.masamaso.com/""UTF-8");
                HtmlAgilityPack.HtmlNodeCollection node = nodes.SelectNodes("//div[@id='newsSlider']/div[@class='index_banner']/ul[@class='slides']/li");//"//div[@class='slideBannerA homeSlideAD1']"

                string[] strLink = new string[node.Count];
                string[] strImg = new string[node.Count];
                string[] strAlt = new string[node.Count];
                string[] strPrice = new string[node.Count];
                string[] strCurrentPrice = new string[node.Count];

                int i = 0;
                foreach (HtmlNode htmlNode in node)
                {
                    try
                    {
                        strLink[i] = htmlNode.ChildNodes[1].Attributes["href"].Value;
                        //strAlt[i] = htmlNode.ChildNodes[1].ChildNodes[0].Attributes["title"].Value;
                        strImg[i++] = htmlNode.ChildNodes[1].ChildNodes[1].Attributes["src"].Value;
                        //strPrice[i] = htmlNode.ChildNodes[6].ChildNodes[1].ChildNodes[1].InnerHtml.Trim().Replace("¥", "");
                        
    //strCurrentPrice[i++] = htmlNode.ChildNodes[3].ChildNodes[1].ChildNodes[1].ChildNodes[0].InnerHtml.Trim().Replace("¥", "");
                    }
                    catch
                    { }
                }
            }

            private void button17_Click(object sender, EventArgs e)
            {
                //从省一点获取所以电商的图标
                HtmlAgilityPack.HtmlNode nodes = GetHtmlNodeFromLink("http://www.sheng1dian.com/Company/Home""UTF-8");
                HtmlAgilityPack.HtmlNodeCollection node = nodes.SelectNodes("//div[@class='CompanyHomeContent']/div[@class='HomeContentBox']");//"//div[@class='slideBannerA homeSlideAD1']"

                string[] strLink = new string[node.Count];
                string[] strImg = new string[node.Count];
                string[] strAlt = new string[node.Count];
                string[] strPrice = new string[node.Count];
                string[] strCurrentPrice = new string[node.Count];

                int i = 0;
                foreach (HtmlNode htmlNode in node)
                {
                    try
                    {
                        //strLink[i] = htmlNode.InnerHtml;
                        strAlt[i] = htmlNode.ChildNodes[1].ChildNodes[1].ChildNodes[0].Attributes["alt"].Value;
                        strImg[i++] = htmlNode.ChildNodes[1].ChildNodes[1].ChildNodes[0].Attributes["src"].Value;
                        //strPrice[i] = htmlNode.ChildNodes[6].ChildNodes[1].ChildNodes[1].InnerHtml.Trim().Replace("¥", "");
                        
    //strCurrentPrice[i++] = htmlNode.ChildNodes[3].ChildNodes[1].ChildNodes[1].ChildNodes[0].InnerHtml.Trim().Replace("¥", "");
                    
                    
                    }
                    catch
                    { }
                }
            }

            private void button18_Click(object sender, EventArgs e)
            {
                //http://www.moonbasa.com/  小产品列表
                HtmlAgilityPack.HtmlNode nodes = GetHtmlNodeFromLink("http://www.moonbasa.com/""UTF-8");
                HtmlAgilityPack.HtmlNodeCollection node = nodes.SelectNodes("//div[@class='large_chest']/ul[1]/li");//"//div[@class='slideBannerA homeSlideAD1']"

                string[] strLink = new string[node.Count];
                string[] strImg = new string[node.Count];
                string[] strAlt = new string[node.Count];
                string[] strPrice = new string[node.Count];
                string[] strCurrentPrice = new string[node.Count];

                int i = 0;
                foreach (HtmlNode htmlNode in node)
                {
                    try
                    {
                        if (htmlNode.Attributes["class"] == null || htmlNode.Attributes["class"].Value != "big")
                        {
                            string link =  htmlNode.ChildNodes[2].Attributes["href"].Value;
                            strLink[i] = link.StartsWith("http") ? link : "http://www.moonbasa.com" + link;
                            strAlt[i] = htmlNode.ChildNodes[2].InnerHtml.Trim();
                            strImg[i] = htmlNode.ChildNodes[0].ChildNodes[0].Attributes["src"].Value;
                            strPrice[i] = htmlNode.ChildNodes[4].ChildNodes[0].InnerHtml.Trim().Replace("""");
                            strCurrentPrice[i++] = htmlNode.ChildNodes[4].ChildNodes[2].InnerHtml.Trim().Replace("""");
                        }
                    }
                    catch
                    { }
                }
            }

            private void button19_Click(object sender, EventArgs e)
            {

                //http://www.moonbasa.com/  衬衫列表
                HtmlAgilityPack.HtmlNode nodes = GetHtmlNodeFromLink("http://www.monteamor.com/channel/chenshan""UTF-8");
                HtmlAgilityPack.HtmlNodeCollection node = nodes.SelectNodes("//div[@class='plist']/dl");//"//div[@class='slideBannerA homeSlideAD1']"

                string[] strLink = new string[node.Count];
                string[] strImg = new string[node.Count];
                string[] strAlt = new string[node.Count];
                string[] strPrice = new string[node.Count];
                string[] strCurrentPrice = new string[node.Count];

                int i = 0;
                foreach (HtmlNode htmlNode in node)
                {
                    try
                    {
                        strImg[i] = htmlNode.ChildNodes[1].ChildNodes[0].ChildNodes[1].Attributes["src"].Value;
                        strLink[i] = "http://www.monteamor.com" + htmlNode.ChildNodes[3].ChildNodes[0].Attributes["href"].Value;
                        strAlt[i] = htmlNode.ChildNodes[3].ChildNodes[0].InnerHtml.Trim();
                        strPrice[i] = htmlNode.ChildNodes[3].ChildNodes[2].InnerHtml.Trim().Replace("""").Replace(" """);
                        strCurrentPrice[i++] = htmlNode.ChildNodes[3].ChildNodes[3].InnerHtml.Trim().Replace("""");
                    }
                    catch
                    { }
                }
            }

            private void button20_Click(object sender, EventArgs e)
            {
                //www.vjia.com   广告
                HtmlAgilityPack.HtmlNode nodes = GetHtmlNodeFromLink("http://www.vjia.com/""UTF-8");
                HtmlAgilityPack.HtmlNodeCollection node = nodes.SelectNodes("//div[@class='scrollwrapper']/div[@class='imgBox']/div[@class='layt']/ul/li/a");//"//div[@class='slideBannerA homeSlideAD1']"

                string[] strLink = new string[node.Count];
                string[] strImg = new string[node.Count];
                string[] strAlt = new string[node.Count];
                string[] strPrice = new string[node.Count];
                string[] strCurrentPrice = new string[node.Count];

                int i = 0;
                foreach (HtmlNode htmlNode in node)
                {
                    try
                    {
                        strImg[i] = htmlNode.ChildNodes[0].Attributes["src"].Value;
                        strLink[i] = htmlNode.Attributes["href"].Value;
                        strAlt[i++] = htmlNode.ChildNodes[0].Attributes["alt"].Value;
                        //strPrice[i] = htmlNode.ChildNodes[3].ChildNodes[2].InnerHtml.Trim().Replace("¥", "").Replace(" ", "");
                        
    //strCurrentPrice[i] = htmlNode.ChildNodes[3].ChildNodes[3].InnerHtml.Trim().Replace("¥", "");
                    }
                    catch
                    { }
                }
            }

            private void button21_Click(object sender, EventArgs e)
            {

                //www.vjia.com   广告
                HtmlAgilityPack.HtmlNode nodes = GetHtmlNodeFromLink("http://www.vjia.com/""UTF-8");
                //HtmlAgilityPack.HtmlNodeCollection 
                     IEnumerable<HtmlNode> node = nodes.SelectNodes("//div[@class='scrollwrapper']/div[@class='imgBox']/div[@class='layt']").Descendants("a");//"//div[@class='slideBannerA homeSlideAD1']"

                string[] strLink = new string[node.Count()];
                string[] strImg = new string[node.Count()];
                string[] strAlt = new string[node.Count()];
                string[] strPrice = new string[node.Count()];
                string[] strCurrentPrice = new string[node.Count()];

                int i = 0;
                foreach (HtmlNode htmlNode in node)
                {
                    try
                    {
                        strImg[i] = htmlNode.ChildNodes[0].Attributes["src"].Value;
                        strLink[i] = htmlNode.Attributes["href"].Value;
                        strAlt[i++] = htmlNode.ChildNodes[0].Attributes["alt"].Value;
                        //strPrice[i] = htmlNode.ChildNodes[3].ChildNodes[2].InnerHtml.Trim().Replace("¥", "").Replace("&nbsp;", "");
                        
    //strCurrentPrice[i] = htmlNode.ChildNodes[3].ChildNodes[3].InnerHtml.Trim().Replace("¥", "");
                    }
                    catch
                    { }
                }
            }

            private void button22_Click(object sender, EventArgs e)
            {
                //http://www.rutisher.com/  产品列表 
                HtmlAgilityPack.HtmlNode nodes = GetHtmlNodeFromLink("http://www.rutisher.com/""UTF-8");
            HtmlAgilityPack.HtmlNodeCollection node = nodes.SelectNodes("//div[@class='large_chest']/ul/li");//"//div[@class='slideBannerA homeSlideAD1']"

                string[] strLink = new string[node.Count];
                string[] strImg = new string[node.Count];
                string[] strAlt = new string[node.Count];
                string[] strPrice = new string[node.Count];
                string[] strCurrentPrice = new string[node.Count];

                int i = 0;
                foreach (HtmlNode htmlNode in node)
                {
                    try
                    {
                        strImg[i] = htmlNode.ChildNodes[1].ChildNodes[1].Attributes["src"].Value;
                        strAlt[i] = htmlNode.ChildNodes[1].ChildNodes[1].Attributes["alt"].Value;
                        strLink[i] = "http://www.rutisher.com" + htmlNode.ChildNodes[1].Attributes["href"].Value;
                        strCurrentPrice[i] = htmlNode.ChildNodes[3].ChildNodes[0].InnerHtml.Trim().Replace("""").Replace("&nbsp;""");
                        strPrice[i++] = htmlNode.ChildNodes[3].ChildNodes[2].InnerHtml.Trim().Replace("""");
                    }
                    catch
                    { }
                }

            }
            /// <summary>
            
    /// 风格秀场
            
    /// </summary>
            
    /// <param name="sender"></param>
            
    /// <param name="e"></param>
            private void button23_Click(object sender, EventArgs e)
            {
                HtmlAgilityPack.HtmlNode nodes = GetHtmlNodeFromLink("http://www.taobao.com/market/sale/lyq.php");
    HtmlAgilityPack.HtmlNodeCollection node = nodes.SelectNodes("//div[@class='s-syshow-wrap']/ul[@class='s-ilist2 clearfix']/li");//"//div[@class='slideBannerA homeSlideAD1']"

                string[] strLink = new string[node.Count];
                string[] strImg = new string[node.Count];
                string[] strAlt = new string[node.Count];
                string[] strPrice = new string[node.Count];
                string[] strCurrentPrice = new string[node.Count];

                int i = 0;
                foreach (HtmlNode htmlNode in node)
                {
                    try
                    {
                        strImg[i] = htmlNode.ChildNodes[1].ChildNodes[0].Attributes["src"].Value;
                        //strAlt[i] = htmlNode.ChildNodes[0].ChildNodes[0].ChildNodes[1].ChildNodes[1].Attributes["alt"].Value;
                        strLink[i++] = htmlNode.ChildNodes[1].Attributes["href"].Value;
                        //strCurrentPrice[i] = htmlNode.ChildNodes[0].ChildNodes[0].ChildNodes[3].ChildNodes[3].InnerHtml.Trim().Replace("¥", "").Replace("&nbsp;", "");
                        
    //strPrice[i] = htmlNode.ChildNodes[3].ChildNodes[2].InnerHtml.Trim().Replace("¥", "");
                    
                    }
                    catch
                    { }
                }
            }


            /// <summary>
            
    /// 女装GALEEty广告
            
    /// </summary>
            
    /// <param name="sender"></param>
            
    /// <param name="e"></param>
            private void button15_Click(object sender, EventArgs e)
            {
                HtmlAgilityPack.HtmlNode nodes = GetHtmlNodeFromLink("http://nvzhuang.taobao.com");
                // HtmlAgilityPack.HtmlNode nodes = GetHtmlNodeFromLink("http://www.suning.com/webapp/wcs/stores/servlet/pcd_10052_10051_-7_N_88507_161007_.html","utf-8");
                HtmlAgilityPack.HtmlNodeCollection node = nodes.SelectNodes("//ul[@class='ks-switchable-content']/li");//"//div[@class='slideBannerA homeSlideAD1']"

                string[] strLink = new string[node.Count];
                string[] strImg = new string[node.Count];
                string[] strAlt = new string[node.Count];
                string[] strPrice = new string[node.Count];
                string[] strCurrentPrice = new string[node.Count];

                int i = 0;
                foreach (HtmlNode htmlNode in node)
                {
                    try
                    {
                        HtmlNode hn = HtmlNode.CreateNode(htmlNode.OuterHtml);
                        HtmlNode nn = hn.SelectSingleNode("//a[1]");
                        strLink[i] = nn.Attributes["href"].Value;
                        strImg[i++] = nn.ChildNodes[1].Attributes["src"].Value;
                    }
                    catch
                    { }
                }
            }

            private void button24_Click(object sender, EventArgs e)
            {
                // 淘宝 女装/女士精品
                HtmlAgilityPack.HtmlNode nodes = GetHtmlNodeFromLink("http://list.taobao.com/market/nvzhuang2011a.htm");//http://list.taobao.com/market/nvzhuang2011a.htm?s=42/84/126/168
                HtmlAgilityPack.HtmlNodeCollection node = nodes.SelectNodes("//div[@class='list-ibox']");//"//div[@class='slideBannerA homeSlideAD1']"

                string[] strLink = new string[node.Count];
                string[] strImg = new string[node.Count];
                string[] strAlt = new string[node.Count];
                string[] strPrice = new string[node.Count];
                string[] strCurrentPrice = new string[node.Count];

                int i = 0;
                foreach (HtmlNode htmlNode in node)
                {
                    try
                    {
                        //HtmlNode hn = HtmlNode.CreateNode(htmlNode.OuterHtml);
                        
    //HtmlNode nn = hn.SelectSingleNode("//a[1]");
                        strLink[i] = htmlNode.ChildNodes[1].ChildNodes[1].Attributes["href"].Value;
                        strAlt[i] = htmlNode.ChildNodes[1].ChildNodes[1].InnerHtml.Trim();

                        bool img = htmlNode.ChildNodes[3].ChildNodes[2].ChildNodes[1].Attributes["src"]==null;
                        strImg[i] = img ? htmlNode.ChildNodes[3].ChildNodes[2].ChildNodes[1].Attributes["data-ks-lazyload"].Value : htmlNode.ChildNodes[3].ChildNodes[2].ChildNodes[1].Attributes["src"].Value;
                        strCurrentPrice[i++] = htmlNode.ChildNodes[7].ChildNodes[1].ChildNodes[1].ChildNodes[0].InnerHtml.Trim().Replace("""").Replace("&nbsp;""");
                        //strPrice[i] = htmlNode.ChildNodes[3].ChildNodes[2].InnerHtml.Trim().Replace("¥", "");
                    }
                    catch
                    { }
                }
            }
  • 相关阅读:
    电源锁
    Android的三种网络联接方式
    用tcpdump在手机上抓包
    图片出现波纹的问题
    Android 3.1以后 广播接收器的新机制
    OpenGL坐标
    用Messager进行IPC
    PHP 介绍
    View坐标,MotionEvent坐标, 二者的转换,可视区域
    OpenGL ES
  • 原文地址:https://www.cnblogs.com/bober/p/2239474.html
Copyright © 2020-2023  润新知