zoukankan      html  css  js  c++  java
  • 读取美团购

            /// <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;//网站名
                }
            }
  • 相关阅读:
    A Famous City
    A Famous ICPC Team
    配置单元测试环境,找不到SenTestingKit
    linux解压.tar命令
    语音输入——科大讯飞
    查看dsym错误信息
    工程里关闭arc
    导入签名错误
    mac显示隐藏文件
    类uialertview弹出动画
  • 原文地址:https://www.cnblogs.com/bober/p/2314971.html
Copyright © 2011-2022 走看看