c# - 从 Openweathermap 获取请求返回 (404) 未找到
问题描述
我正在尝试使用以下代码获取天气信息,但每次(除了第一次,但我不确定)我都会收到 404 响应。我做错了什么?
CityName = "鄂木斯克"; API_KEY = "368e827be4b38db51ff960ca88b5c396";
weburl = "http://api.openweathermap.org/data/2.5/weather?q=" + CityName + "&mode=xml&APPID=" + API_KEY;
//weburl = "http://api.openweathermap.org/data/2.5/forecast?id=524901&APPID=368e827be4b38db51ff960ca88b5c396";
doc = new XmlDocument ();
var xml = new WebClient().DownloadString(new Uri (weburl));
doc.LoadXml (xml);
foreach(XmlNode node in doc.GetElementsByTagName("*"))
{
Console.Out.WriteLine(node.Name);
}
解决方案
推荐阅读
- angular8 - 来自 API 调用的 Angular 8 FormGroup 异步验证
- r - 根据 R 中的数据范围计算值
- c# - restsharp PUT 请求错误 --> “StatusCode: InternalServerError, Content-Type: application/json, Content-Length: -1)”
- javascript - 为什么我在使用 Ext JS 6.2.0 时遇到问题?
- alexa-skills-kit - 如何使用 JOVO 框架获取 Alexa 技能意图的实际话语文本
- excel - 有没有办法提高执行时间?
- html - 点击孩子时不要考虑父母
- python - 如何使用 python/selenium 自动执行网站上的按钮点击序列?
- javascript - FullCalendar, 4.2 - 如何在 eventClick 函数上更改事件类
- javascript - 同一对象上的多个事件侦听器不起作用