c# 获取天气预报信息

Uri uri = new Uri("http://api.liqwei.com/weather/?t=1");
    WebRequest wreq = WebRequest.Create(uri);
    HttpWebResponse wresp = (HttpWebResponse)wreq.GetResponse();
    string HTML = "";        //最终包含天气信息的字符串
    Stream s = wresp.GetResponseStream();
    StreamReader objReader = new StreamReader(s, System.Text.Encoding.Default);

    string sLine = "";
    int i = 0;

    while (sLine != null)
    {
     i++;
     sLine = objReader.ReadLine();
     if (sLine != null)
      HTML += sLine;
    }

 

posted on 2011-05-31 09:31  风乔  阅读(762)  评论(0编辑  收藏  举报

导航