views:

4637

answers:

4

I'm creating an app (PHP) that takes yahoo weather data from the free RSS feed and correlates it with a colour hex based on data retrieved from the RSS feed. The issue I'm having is finding a way to grab the location code or WOEID without doing it manually.

Yahoos API sends back an RSS feed as long as you provide a WOEID -> http://weather.yahooapis.com/forecastrss?w=4097

Is there an ethical way of doing this? My beginner knowledge tells me I have to write a script that would search yahoo using the term and grab the first WOEID, but I would assume yahoo doesn't want scripts doing this and it seems overcomplicated... If not, are there any alternative APIs that would make this easier on me?

Thanks!

A: 

Yahoo is publishing a service on the web. Why is there an issue if you scrape the WOEID? just wget the page and regex for it. If they didn't want you to do that, they would make you hit a TOS page and click accept before you accessed the content...

Zak
+13  A: 

Why not just use the Yahoo! GeoPlanet service to resolve a place to a WOEID? Or use the YQL service to access GeoPlanet via it's table?

http://where.yahooapis.com/v1/places.q('Barrie CA')?appid=[yourappidhere]

or

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.places%20where%20text%3D%22Barrie%20CA%22&format=xml

No need for scraping.

Cheers

G

(Disclosure; I work for Yahoo! and am part of the group behind WOEIDs and GeoPlanet)

vicchi
Thanks Vicchi!You guys do a wonderful job of making it easy for beginners like me to learn!
askon
Holy smokes, this answer is class. Just what I was looking for
Brian Bishop
A: 

The RSS feed returns just two days in the forecast. Is there a way to get a longer forecast dynamically?

Thanks!

Michael Bachman
A: 

Is there any way to dynamically populate the cities upon selecting the country from a drop down list and thus generating the woeid for it?

Thanks Jaseem

jaseem Ambalangadan