Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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?

  1. Search the city you are looking for (in my case: http://weather.yahoo.com/venezuela/anzoategui/lecheria-420107/)

  2. View Source code of that page (In Google Chrome: right clic --> View Page Source. Sorry, I like to be specific).

  3. In the code, search for: "weather.com/weather/extended"

  4. The identifier of the city is the value next to that link, in my case: VEXX0025

Hope this tip can help anybody!

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top