网上搜索了一下,有几个提供的webservice都说是数据来源是中国气象局;
还有人说中国气象局有提供 天气预报的webservice, 但是我找了半天没有找到。。。。
英文: http: // www. webservicex. net/globalweather.asmx
调用: GetWeather...
http: //www. webxml. com. cn/WebServices/WeatherWebService.asmx
ASP.NET 2.0 抓取天气~非常简单~2008年01月04日 星期五 下午 09:57//Webclient:
private void GetWeather1()
{
url = "http: //weather. news.qq. com/inc/dc296.htm";
WebClient wc = new WebClient();
byte[] pageData = wc.DownloadData(url);
string resultStr = Encoding.Default.GetString(pageData);//GB2312
response.write(resultStr);
}
//httpWebrequest:
private void GetWeather2()
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http ://weather. news. qq.com/inc/dc296.htm");
request.Method = "Get";
request.ContentType = "application/x-www-form-urlencoded";
WebResponse response = request.GetResponse();
Stream s = response.GetResponseStream();
StreamReader sr = new StreamReader(s,System.Text.Encoding.GetEncoding("GB2312"));
string html = sr.ReadToEnd();
s.Close();
sr.Close();
Response.Write(html.Replace("/images/","http: // weather. news.qq. com/images/"));
}