读取美团购

        /// <summary>
        
/// 读取美团团购
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>
        private void button43_Click(object sender, EventArgs e)
        {
            XmlDocument xml= new XmlDocument();
            if (!Directory.Exists(Environment.CurrentDirectory + "/data.xml"))
            {
                Uri uri = new Uri("http://api.union.meituan.com/data/hao123v2/key/qtkECZsy0px6cwufQlIA2b3g7zSDNejU");

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
                WebResponse response = request.GetResponse();

                Stream stream = response.GetResponseStream();
                StreamReader read = new StreamReader(stream, Encoding.GetEncoding("UTF-8"));
                string tuan = read.ReadToEnd().Replace("<data>""").Replace("<display>""").Replace("</data>""").Replace("</display>""");

                xml.LoadXml(tuan);
                xml.Save(Environment.CurrentDirectory + "/data.xml");
            }
            else
                xml.Load(Environment.CurrentDirectory + "/data.xml");

            XmlNodeList list = xml.GetElementsByTagName("url");
            foreach (XmlNode node in list)
            {
                string[] x = new string[21];//
                x[0] = node.ChildNodes[0].InnerText;//地址
                x[1] = node.ChildNodes[1].InnerText;//电话
                x[2] = node.ChildNodes[2].InnerText;//商家
                x[3] = node.ChildNodes[3].InnerText;//名称
                x[4] = node.ChildNodes[4].InnerText;//
                x[5] = node.ChildNodes[5].InnerText;//
                x[6] = node.ChildNodes[6].InnerText;//现价
                x[7] = node.ChildNodes[7].InnerText;//原价
                x[8] = node.ChildNodes[8].InnerText;//开始时间
                x[9] = node.ChildNodes[9].InnerText;//结束时间
                x[10] = node.ChildNodes[10].InnerText;//图片地址
                x[11] = node.ChildNodes[11].InnerText;//标题
                x[12] = node.ChildNodes[12].InnerText;//
                x[13] = node.ChildNodes[13].InnerText;//地址
                x[14] = node.ChildNodes[14].InnerText;////区域
                x[15] = node.ChildNodes[15].InnerText;//
                x[16] = node.ChildNodes[16].InnerText;//类别
                x[17] = node.ChildNodes[17].InnerText;//
                x[18] = node.ChildNodes[18].InnerText;//城市
                x[19] = node.ChildNodes[19].InnerText;//城市地址
                x[20] = node.ChildNodes[20].InnerText;//网站名
            }
        }
posted @ 2012-01-06 17:25  Care健康  阅读(207)  评论(1编辑  收藏  举报
版权
作者:Bober Song

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

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

推荐空间:华夏名网

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

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