1

I am using the jQuery plugin jquery.simpleweather to query for Yahoo weather for a specific zip code and I get the response back in JSON format. One of the keys returned is called "link" which provides a link to the "Full Forecast". This used to work just fine, but now (as of around the beginning of this month) the links it provides just ports the user to the yahoo weather home page. I'm assuming they must have made some kind of change to the way things work. Anyway an example of this is if I say provide the zip code of 93065 which is "Simi Valley, CA" the link gets returned in the JSON repsonse like this:

http://us.rd.yahoo.com/dailynews/rss/weather/Simi_Valley__CA/*http://weather.yahoo.com/forecast/USCA1060_f.html

The link looks very screwy, but that's what gets returned in the response and if you attempt to GO to that link, it just ports you to the default yahoo weather page instead of the forecast for that city.

Is there are a way maybe to create my own link? I am trying to figure out how to just hot link to the yahoo weather page for 93065. I can construct the link in my code. The problem is it doesn't look straight forward. If I do a google search for "yahoo weather 93065", and click on the first search result the link is this

https://weather.yahoo.com/united-states/california/simi-valley-2493889/

The problem is I don't know what that "2493889" is or how to capture that value. I was hoping I could just create a link like this

https://weather.yahoo.com/united-states/california/93065/

but that doesn't work. How can I just hot link to a yahoo weather page when all I have is the zip code and the city name?

THANKS

Erich H.
  • 467
  • 1
  • 9
  • 28

2 Answers2

1

Looks like yahoo's weather API hasn't been updated to match their new weather landing.

A work VERY around could be to simply ignore the numbers.

https://weather.yahoo.com/united-states/california/simi-valley/

I would only do this long enough to implement using another API like Open Weather Map or Weather Underground (I'd link but not enough reputation to post more than 2 links).

An additional note, I did a quick search through Yahoo's API forums and didn't see any discussion on this topic, although there might be some contact or email address that can be used to inform them of the bug in their API.

cjdierkens
  • 11
  • 1
0

I have a work-around which is hacky, in that it seems like the Yahoo Weather API is returning values different than their documentation.

In any case, if you know the woeid, you can (as of May 2015) construct a link to the forecast as such:

// San Francisco WOEID
var woe = '2487956';
// call simpleweather
$.simpleWeather({
  woeid: woe,
  unit : 'f',
  success : function( weather ) {
    // 'parts'      array of values needed from 'weather'
    // 'link'       object to hold modified 'weather' values
    // 'forecast'   forecast link 
    var parts = ['country','region','city'],
      link = {}, 
      forecast = 'https://weather.yahoo.com/';
    // lowercase the returned values and replace spaces with dashes
    $.each( parts, function(i,v) {
      link[v] = weather[v].replace(/\s+/g,'-').toLowerCase();
    });
    // build forecast link
    forecast += link.country + '/' + link.region + '/' + link.city + '-' + woe + '/';
  },
});

I'm sure there are more efficient ways to do the above...

greenbank
  • 21
  • 2