如何根据ip地址获取天气 再根据天气情况显示本地的某张图片 有源码最好!!!!

解决方案 »

  1.   

    简单的可以参见IP地址总表:   
      http://transtaafl.com/i/200405/200405070625552170581221063195.asp   
      http://www.100ci.com/forum/dispbbs.asp?boardid=18&id=107  
    设计IP对应城市的数据库。
    获取天气的一段代码。static string GetWeatherInfo(string s1, string s2)
            {
                string ResponseText;
                string text;
                int startIndex;
                int endIndex;
                Uri url = new Uri(@"http://firetear.com/weather/lvweather.aspx");
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
                HttpWebResponse res = (HttpWebResponse)req.GetResponse();
                req.Method = "Post";
                StreamReader ReaderText = new StreamReader(res.GetResponseStream(), Encoding.UTF8);
                ResponseText = ReaderText.ReadToEnd();
                res.Close();
                startIndex = ResponseText.IndexOf(s1) + s1.Length;
                endIndex = ResponseText.IndexOf(s2);
                text = ResponseText.Substring(startIndex, endIndex - startIndex);
                return text;
            }        private void Form1_Load(object sender, EventArgs e)
            {
                Label1.Text = GetWeatherInfo(@"g>", @"</");
                Label2.Text = GetWeatherInfo(@"天气:", @",紫");
            }楼主多思。
      

  2.   

    你好,需要IP数据库的支持,也可以通过调用接口实现,有些代码,例子可以看看。http://code-design.cn/codedown75.htmlhttp://program.zz5u.net/net/2009/0306/694.html