读取美团购
/// <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;//网站名
}
}
/// 读取美团团购
/// </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;//网站名
}
}
作者:Bober Song
出处:http://bober.cnblogs.com/
CARE健康网: http://www.aicareyou.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
出处:http://bober.cnblogs.com/
CARE健康网: http://www.aicareyou.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。