zoukankan      html  css  js  c++  java
  • lafaso.com数据获取

            private void button31_Click(object sender, EventArgs e)
            {
                GetHtmlNodeFromLink2("http://www.lafaso.com/clothing/""UTF-8");//http://www.vancl.com/channel/women.html  children
                HtmlAgilityPack.HtmlNodeCollection node = htmlNodes.SelectNodes("//div[@class='clothing_new clothing_moban']/textarea/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"].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].InnerHtml.Trim();
                        //strMarketPrice[i] = htmlNode.ChildNodes[3].ChildNodes[3].InnerHtml.Trim().Replace("¥", "").Replace("¥", "");
                        strCurrentPrice[i++] = htmlNode.ChildNodes[2].ChildNodes[0].ChildNodes[0].InnerHtml.Trim().Replace("乐蜂价:¥""");
                    }
                    catch
                    { }
                }
            }

            private void button32_Click(object sender, EventArgs e)
            {
    GetHtmlNodeFromLink2("http://www.lafaso.com/clothing/""UTF-8");//http://www.vancl.com/channel/women.html  children
    HtmlAgilityPack.HtmlNodeCollection node = htmlNodes.SelectNodes("//div[@class='clothing_new clothing_shirt clothing_kz clothing_moban']/textarea/ul/li");//"//div[@class='slideBannerA homeSlideAD1']"
    //clothing_new clothing_shirt clothing_moban
                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"].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].InnerHtml.Trim();
                        //strMarketPrice[i] = htmlNode.ChildNodes[3].ChildNodes[3].InnerHtml.Trim().Replace("¥", "").Replace("¥", "");
                        strCurrentPrice[i++] = htmlNode.ChildNodes[2].ChildNodes[0].ChildNodes[0].InnerHtml.Trim().Replace("乐蜂价:¥""");
                    }
                    catch
                    { }
                }
            }

            private void button33_Click(object sender, EventArgs e)
            {

    GetHtmlNodeFromLink2("http://www.lafaso.com/clothing/""UTF-8");//http://www.vancl.com/channel/women.html  children
    HtmlAgilityPack.HtmlNodeCollection node = htmlNodes.SelectNodes("//div[@class='clothing_new clothing_shirt clothing_moban']/textarea/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"].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].InnerHtml.Trim();
                        //strMarketPrice[i] = htmlNode.ChildNodes[3].ChildNodes[3].InnerHtml.Trim().Replace("¥", "").Replace("¥", "");
                        strCurrentPrice[i++] = htmlNode.ChildNodes[2].ChildNodes[0].ChildNodes[0].InnerHtml.Trim().Replace("乐蜂价:¥""");
                    }
                    catch
                    { }
                }
            }

            private void button34_Click(object sender, EventArgs e)
            {

    GetHtmlNodeFromLink2("http://www.lafaso.com/clothing/""UTF-8");//http://www.vancl.com/channel/women.html  children
    HtmlAgilityPack.HtmlNodeCollection node = htmlNodes.SelectNodes("//div[@class='clothing_new clothing_shirt clothing_moban']/textarea/p");//"//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"].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].InnerHtml.Trim();
                        
    //strMarketPrice[i] = htmlNode.ChildNodes[3].ChildNodes[3].InnerHtml.Trim().Replace("¥", "").Replace("¥", "");
                        
    //strCurrentPrice[i] = htmlNode.ChildNodes[2].ChildNodes[0].ChildNodes[0].InnerHtml.Trim().Replace("乐蜂价:¥", "");
                    }
                    catch
                    { }
                }
            }

            private void button35_Click(object sender, EventArgs e)
            {

    GetHtmlNodeFromLink2("http://www.lafaso.com/clothing/""UTF-8");//http://www.vancl.com/channel/women.html  children
    HtmlAgilityPack.HtmlNodeCollection node = htmlNodes.SelectNodes("//div[@class='clothing_new clothing_shirt clothing_kz clothing_moban']/textarea/p");//"//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"].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].InnerHtml.Trim();
                        
    //strMarketPrice[i] = htmlNode.ChildNodes[3].ChildNodes[3].InnerHtml.Trim().Replace("¥", "").Replace("¥", "");
                        
    //strCurrentPrice[i] = htmlNode.ChildNodes[2].ChildNodes[0].ChildNodes[0].InnerHtml.Trim().Replace("乐蜂价:¥", "");
                    }
                    catch
                    { }
                }
            }
  • 相关阅读:
    剑指05两个栈实现一个队列
    11 幂等 Idempotence
    13 SOAP
    leetcode143zigzag-conversion
    如何使用 awk 复合表达式
    IT 运行在云端,而云运行在 Linux 上
    Docker1.12 + Swarm 构建动态微服务应用
    教你在Ubuntu上体验Mac风格
    Zabbix-3.0.3结合Grafana-3.1.0给你想要的绘图
    Zabbix-3.0.3使用自带模板监控MySQL
  • 原文地址:https://www.cnblogs.com/bober/p/2244758.html
Copyright © 2011-2022 走看看