国家气象局最新的天气预报API是哪个?

u010018424 2015-07-23 07:34:36
http://m.weather.com.cn/atad/101010100.html
这个是最新的貌似是更新到2015年6月18号就停止了。
有哪位知道最新的接口?
或者有没有其他可用的接口,json格式的?
...全文
754 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
RookieDemo 2016-01-12
  • 打赏
  • 举报
回复
你现在做什么样了 有问题想请教
by_封爱 版主 2015-07-24
  • 打赏
  • 举报
回复

 public static string GetWeather(string area)
        {
            var url = "http://m.weather.com.cn/atad/" + area + ".html";
            var client = new System.Net.WebClient() { Encoding = System.Text.Encoding.UTF8 };
            var rs = client.DownloadString(url);
            return rs;
        }
目前是这个地址..不过人家并没有说这是所谓的API.. 如果要API另外有开放平台LZ可以用公司的信息进行申请key(我已经申请下来并且在用了)

/// <summary>
    /// 天气接口
    /// 文档:http://openweather.weather.com.cn/Home/Help/common.html
    /// </summary>
    public class weather
    {
        public static string GetWeather(string area, string appid, string private_key)
        {
            var date = DateTime.Now.ToString("yyyyMMddHHmm");
            var url = "http://open.weather.com.cn/data/?areaid=" + area;
            url += "&type=forecast_v";
            url += "&date="+date;
            url += "&appid=" + appid.Substring(0,6);

            var public_key = url + appid.Substring(6, appid.Length - 6);
            var key = Base64Encode(hash_hmac(public_key, private_key));
            url += "&key=" + System.Web.HttpUtility.UrlEncode(key);
         
            var client = new System.Net.WebClient() { Encoding = System.Text.Encoding.UTF8 };
            var rs = client.DownloadString(url);
            return rs;
        }
        public static byte[] hash_hmac(string signatureString, string secretKey)
        {
            var enc = Encoding.UTF8;
            HMACSHA1 hmac = new HMACSHA1(enc.GetBytes(secretKey));
            hmac.Initialize();
            byte[] buffer = enc.GetBytes(signatureString);
            return hmac.ComputeHash(buffer);
        }
        public static string Base64Encode(byte [] data)
        {
            return Convert.ToBase64String(data);
        }
    }
caoqinghua 2015-07-24
  • 打赏
  • 举报
回复
直接采集http://www.weather.com.cn/weather1d/101010500.shtml
  • 打赏
  • 举报
回复
很小气的,别提了,不如用采集方法.
u010018424 2015-07-23
  • 打赏
  • 举报
回复
哪位大哥指点一下?

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧