/// <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;//网站名
            }
        }

相关文章:

  • 2021-07-07
  • 2021-08-27
  • 2021-11-30
  • 2021-12-09
  • 2022-12-23
  • 2021-08-05
  • 2021-11-09
猜你喜欢
  • 2022-12-23
  • 2021-10-04
  • 2021-06-01
  • 2021-07-06
  • 2022-01-22
  • 2021-11-17
  • 2021-12-03
相关资源
相似解决方案