https://www.myziyuan.com/
- 11212121
- 两个网站都有一个API,它似乎是Web服务的界面。
- 2021-06-22 19:50:38
- ee
- 这个问题对于那些没有学到的人有点困难........给你一些参考,我写了天气网络的类,注意缓存。公共静态类Weatheronhead {公共静态字符串getWeather(string wealthurl){if(system.web.httpcontext.current.cache [天气“== null){system.web.httpcontext.current.cache.add(”天气“ ,CatchWeatherInfo(Wealthurl),null,datetime.now.addminutes(60),timespan.zero,system.web.caching.cacheitempriority.normal,null); return(string)system.web.httpcontext.current.cache [“天气“”];}公共静态字符串CatchWeatherInfo(String Wealthurl){String Content =“”; httpwebrequest requser =(httpwebrequest)webrequest.create(Wealthurl); requser.keepalive = false; httpwebreesons响应;尝试{响应r =(httpwebresponse)requser.getResponse(); system.text.encoding utf8 = system.text.encoding.utf8; StreamResponse = Orking er.getResponseStream(); StreamReader StreamRead = New StreamReader(StreamResponse,UTF8); char [] readbuff = new char [256]; int count = streamread.read(readbuff,0,256); while(count> 0){string outputdata =新字符串(readbuff,0,count);内容+ = outputData; count = streamread.read(readbuff,0,256); streamresponse.close();返回内容;} catch(webException ex){content =“在请求的URL时生成错误:”+ Wealthurl +“,错误消息是”+ EX。 ToString()返回Weath返回时;}}} eronhead.getWeather(“”); 。 。 。对初学者来说太难了.......
- 2021-06-22 19:49:40
- wolf8668
- 如何在.NET中的Windows应用程序实现天气预报,找个WebService提供天气预报服务的好像google就有提供吧你给它参数城市邮编区号之类的它就给你返回一个xml格式的结果,然后你解析下,显示在WinFrom上就可以了啊你搜索“WebService”和“WinFrom调用Service” 就会有结果的
- 2021-06-22 19:49:40