Fork me on GitHub

API读取百度天气

  1. string url ="http://api.map.baidu.com/telematics/v3/weather?location=昌图&output=json&ak=************";
  2. WebClient wc =newWebClient();
  3. wc.Encoding=Encoding.UTF8;
  4. var txt = wc.DownloadString(url);
  5. var xx =JsonConvert.DeserializeObject<BaiduWeather>(txt);
  1. publicclassIndex
  2. {
  3. publicstringTitle{ get;set;}
  4. publicstringZs{ get;set;}
  5. publicstringTipt{ get;set;}
  6. publicstringDes{ get;set;}
  7. }
  8. publicclassWeather_data
  9. {
  10. publicstringDate{ get;set;}
  11. publicstringDayPictureUrl{ get;set;}
  12. publicstringNightPictureUrl{ get;set;}
  13. publicstringWeather{ get;set;}
  14. publicstringWind{ get;set;}
  15. publicstringTemperature{ get;set;}
  16. }
  17. publicclassResults
  18. {
  19. publicstringCurrentCity{ get;set;}
  20. publicstringPm25{ get;set;}
  21. publicList<Index>Index{ get;set;}
  22. publicList<Weather_data>Weather_data{ get;set;}
  23. }
  24. publicclassBaiduWeather
  25. {
  26. publicintError{ get;set;}
  27. publicstringStatus{ get;set;}
  28. publicDateTimeDate{ get;set;}
  29. publicList<Results>Results{ get;set;}
  30. }
 
posted @ 2017-06-04 10:08  开发软件  阅读(1048)  评论(0编辑  收藏  举报