雅虎天气 api 仅适用于美国城市!?
我能够找到美国城市的天气预报,我想将其扩展到印度城市。如果我能为世界上所有的城市做这件事就更好了。这是我正在使用的代码。
import pywapi
import string
yahoo_result = pywapi.get_weather_from_yahoo('RSXX0199', 'metric')
print "Yahoo says: It is " + string.lower(yahoo_result['condition']['text']) + " and " + yahoo_result['condition']['temp'] + "C now in New York.\n\n"`
我无法找到印度各州、城市代码的代码,我可以将其替换为 RSXX0199
。顺便说一句,我使用 Python API 来处理天气,它内部使用雅虎的天气 API。
请帮帮我。
谢谢。
I'm able to find weather report of cities of US and I want to extend it for the cities in India. It will be still better if I could do it for all the cities in the world. This is the code i was using.
import pywapi
import string
yahoo_result = pywapi.get_weather_from_yahoo('RSXX0199', 'metric')
print "Yahoo says: It is " + string.lower(yahoo_result['condition']['text']) + " and " + yahoo_result['condition']['temp'] + "C now in New York.\n\n"`
I'm not able to find a code for Indian states, cities codes, for which i can replace with RSXX0199
. By the way, I'm using Python API for weather, which internally uses Yahoo's weather API.
Please help me out.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您查看某个位置的 RSS 提要,您要查找的标识符就在其地址中。
例如,印度 Karimnagar 的 RSS 源是“天气”。 yahooapis.com/forecastrss?p=INXX0358&u=f",可以通过单击 RSS 按钮来检索右上角。
If you look at the RSS feed of an individual location, the identifier you are looking for is in it's address.
For instance, Karimnagar, India's RSS feed is "weather.yahooapis.com/forecastrss?p=INXX0358&u=f" and can be retrieved by clicking the RSS button in the top right.
您可以对 http://weather.yahoo.com/ 中列出的世界上任何城市使用 Yahoo Weather API
如何知道城市的标识符?
搜索您要查找的城市(在我的例子中:http://weather.yahoo.com/venezuela/anzoategui/lecheria-420107/ )
查看该页面的源代码(在 Google Chrome 中:右键 --> 查看页面源代码。抱歉,我喜欢具体一点)。
在代码中,搜索:“weather.com/weather/extended”
城市的标识符就是值在该链接旁边,在我的例子中:VEXX0025
希望这个提示可以帮助任何人!
You can use Yahoo Weather API with any city of the world listed in http://weather.yahoo.com/
How to know the identifier of the city?
Search the city you are looking for (in my case: http://weather.yahoo.com/venezuela/anzoategui/lecheria-420107/)
View Source code of that page (In Google Chrome: right clic --> View Page Source. Sorry, I like to be specific).
In the code, search for: "weather.com/weather/extended"
The identifier of the city is the value next to that link, in my case: VEXX0025
Hope this tip can help anybody!
不,我使用他们的 api 构建了一个用于中国天气变化警报的应用程序。
雅虎天气 API 使用 yahoo wdid(代表城市的代码)来请求天气状况。
所以首先你应该得到城市的 wdid。
No,I use their api to build an app for weather change alert in China.
Yahoo weather api use use yahoo wdid(a code stands for a city) to request for the weather condition.
So first you should get the wdid of the city.