该代码位于weather.js的128~184行左右。
MSNWeather.prototype={
SearchByCode:function(locCode){
var self = this;
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=true;
xmlDoc.onreadystatechange = function() {
if (xmlDoc.readyState == 4)
{
if(xmlDoc.parseError.errorCode != 0)
{
}
else
{
var wdata = new WeatherData();
wdata.Latitude = parseFloat(xmlDoc.selectSingleNode("/weatherdata/weather/@lat").value);
wdata.Longitude = parseFloat(xmlDoc.selectSingleNode("/weatherdata/weather/@long").value);
wdata.Location = xmlDoc.selectSingleNode("/weatherdata/weather/@weatherlocationname").value;
wdata.Attribution = xmlDoc.selectSingleNode("/weatherdata/weather/@attribution").value;
wdata.Attribution2= xmlDoc.selectSingleNode("/weatherdata/weather/@attribution2").value;
wdata.Url = xmlDoc.selectSingleNode("/weatherdata/weather/@url").value;
wdata.SkyCode = parseInt(xmlDoc.selectSingleNode("/weatherdata/weather/current/@skycode").value);
wdata.SkyText = getWeatherState(wdata.SkyCode, xmlDoc.selectSingleNode("/weatherdata/weather/current/@skytext").value);
wdata.Temperature = parseInt(xmlDoc.selectSingleNode("/weatherdata/weather/current/@temperature").value);
if (self.Celsius)
wdata.Temperature = convert(wdata.Temperature);
else
wdata.Temperature = isNaN(wdata.Temperature)?0:wdata.Temperature;
for (var i = 1; i <= 5; i++)
{
var node = xmlDoc.documentElement.childNodes[0].childNodes[i];
var SkyCode = parseInt(node.getAttribute("skycodeday"));
var SkyText = getWeatherState(SkyCode, node.getAttribute("skytextday"));
var High = parseInt(node.getAttribute("high"));
if (self.Celsius)
High = convert(High);
else
High = isNaN(High)?0:High;
var Low = parseInt(node.getAttribute("low"));
if (self.Celsius)
Low = convert(parseInt(Low));
else
Low = isNaN(Low)?0:Low;
var Date = node.getAttribute("date");
var Day = node.getAttribute("day");
wdata.makeForeCast(i-1, SkyCode, SkyText, High, Low, Date, Day);
}
wdata.RetCode = 200;
wdata.Count = 1;
self.OnDataReady(wdata);
}
}
};
xmlDoc.load("
http://weather.service.msn.com/data.aspx?src=vista&wealocations="+locCode);
},
OnDataReady:function(data){}
}
由此可见,该小工具访问的网址是:
http://weather.service.msn.com/data.aspx?src=vista&wealocations=位置数据