Fetching weather information from Yahoo.com

May 26, 2006

For fetching weather information for Mumbai region make a HTTP GET request at http://xml.weather.yahoo.com/forecastrss with request parameters as:

Parameter Description Example
p US zip code or Location ID. p=95089
p=USCA1116
u Units for temperature.
f: Fahrenheit
c: Celsius
u=c

So for Mumbai  region query p=INXX0087 and u=c

http://xml.weather.yahoo.com/forecastrss?p=INXX0087

 In response to this request you'll get a XML data containing following elements:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

<rss version="2.0" xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">

<channel>

  <title>Yahoo! Weather – Mumbai, IN</title>

  <link>http://us.rd.yahoo.com/dailynews/rss/weather/

Mumbai__IN/*http://xml.weather.yahoo.com/forecast/

INXX0087_c.html</link>

  <description>Yahoo! Weather for Mumbai, IN</description>

  <language>en-us</language>

  <lastBuildDate>Fri, 26 May 2006 12:10 pm IST</lastBuildDate>

  <ttl>60</ttl>

  <yweather:location city="Mumbai" region="" country="IN" />

  <yweather:units temperature="C" distance="km" pressure="mb" speed="kph" />

  <yweather:wind chill="32" direction="290" speed="14" />

  <yweather:atmosphere humidity="55" visibility="800" pressure="0" rising="2" />

  <yweather:astronomy sunrise="6:01 am" sunset="7:10 pm" />

<image>

  <title>Yahoo! Weather</title>

  <width>142</width>

  <height>18</height>

  <link>http://weather.yahoo.com/</link>

  <url>http://us.i1.yimg.com/us.yimg.com/i/us/nws/th/main_142b.gif</url>

  </image>

<item>

  <title>Conditions for Mumbai, IN at 12:10 pm IST</title>

  <geo:lat>19.12</geo:lat>

  <geo:long>72.83</geo:long>

  <link>http://us.rd.yahoo.com/dailynews/rss/weather/

Mumbai__IN/*http://xml.weather.yahoo.com/forecast/

INXX0087_c.html</link>

  <pubDate>Fri, 26 May 2006 12:10 pm IST</pubDate>

  <yweather:condition text="Partly Cloudy" code="30" temp="32" date="Fri, 26 May 2006 12:10 pm IST" />

<description>

<![CDATA[ <img src="http://us.i1.yimg.com/us.yimg.com/i/us/we/52/30.gif&quot; /><br />
<b>Current Conditions:</b><br />
Partly Cloudy, 32 C<BR /><BR />
<b>Forecast:</b><BR />
  Fri – Partly Cloudy. High: 31 Low: 28<br />
  Sat – Scattered Thunderstorms. High: 30 Low: 27<br />
<br />
<a href="http://us.rd.yahoo.com/dailynews/rss/weather/

Mumbai__IN/*http://xml.weather.yahoo.com/forecast/

INXX0087_c.html">Full Forecast at Yahoo! Weather</a><BR/>
(provided by The Weather Channel)<br/>   ]]> f(clean);

  </description>

  <yweather:forecast day="Fri" date="26 May 2006" low="28" high="31" text="Partly Cloudy" code="30" />

  <yweather:forecast day="Sat" date="27 May 2006" low="27" high="30" text="Scattered Thunderstorms" code="38" />

  <guid isPermaLink="false">INXX0087_2006_05_26_12_10_IST</guid>

  </item>

  </channel>

  </rss>

<!–  p5.weather.dcn.yahoo.com uncompressed Fri May 26 00:35:37 PDT 2006   –> f(clean);

Now the things are bit simple, get a XML reader to read all the required child nodes from the feed.

You need to develop an application which makes a HTTP request and get the XML response.

-Bugs

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: