Because of the discovery of Ajax currently cross-domain a little problem, only in IE can be set to use, so I wrote a simple ASP webservice, in fact, the role is a thief program, Yahoo caught the weather, and then generate XML. Let's start here and then consider adding a database so that the client can read quickly after writing.
Accustomed to use JS to write things, accidentally ASP also take all JS write, oh, have time to change to VB.
I despise him again, Flash is n years ago, although the time lost a bit long, but in the help of AW, slowly will be a improvement.
Finally calmed the fire, but also a quiet change of things.
Copy Code code as follows:
<% @LANGUAGE = "JAVASCRIPT" codepage= "65001"%>
<%
Session.CodePage = "65001"
Response.contenttype= "Text/html"
Response.Expires = 0
var n=request ("N")
var num=request ("id")
var url= "http://xml.weather.yahoo.com/forecastrss?p=" +n+ "&u=c&id=" +num;
var xmldoc=server.createobject ("Microsoft.XMLHTTP");
Xmldoc.open (' Get ', url,false);
Xmldoc.send (NULL);
var response = Xmldoc.responseXML.documentElement;
var lastnode=response.selectnodes ("//rss/channel/lastbuilddate");
var citynode=response.selectnodes ("//rss/channel/yweather:location");
var windnode=response.selectnodes ("//rss/channel/yweather:wind");
var atmospherenode=response.selectnodes ("//rss/channel/yweather:atmosphere");
var astronomynode=response.selectnodes ("//rss/channel/yweather:astronomy");
var conditionnode=response.selectnodes ("//rss/channel/item/yweather:condition");
var forecastnode=response.selectnodes ("//rss/channel/item/yweather:forecast");
var lastv=lastnode (0). Firstchild.nodevalue
Edit Properties
function Attri (a,b,c) {
Return a (b). Attributes.getnameditem (c). Value
}
var Cityv=attri (citynode,0, "City")
var Chillv=attri (windnode,0, "chill")
var Directionv=attri (windnode,0, "direction")
var Speedv=attri (windnode,0, "speed")
var Humidityv=attri (atmospherenode,0, "humidity")
var Visibilityv=attri (atmospherenode,0, "visibility")
var Sunrisev=attri (astronomynode,0, "Sunrise")
var Sunsetv=attri (astronomynode,0, "Sunset")
var Textv=attri (conditionnode,0, "text")
var Codev=attri (conditionnode,0, "code")
var Tempv=attri (conditionnode,0, "temp")
Convert English to Chinese
var citych=en2ch (CITYV)
function en2ch (obj) {
if (obj== "Wuhan") {return "Wuhan"}
else if (obj== "Nanchang") {return "Nanchang"}
else if (obj== "Haikou") {return "Haikou"}
else if (obj== "Beijing") {return "Beijing"}
else if (obj== "Shanghai") {return "Shanghai"}
else if (obj== "Guangzhou") {return "Guangzhou"}
else if (obj== "Yinchuan") {return "Yinchuan"}
else if (obj== "Zhengzhou") {return "Zhengzhou"}
else if (obj== "Changsha") {return "Changsha"}
else if (obj== "Hanzhong") {return "Hangzhou"}
else if (obj== "Hong Kong") {return "Hongkong"}
else if (obj== "Xin '") {return "Xian"}
else if (obj== "Chengdu") {return "Chengdu"}
else if (obj== "Qingdao") {return "Qingdao"}
else if (obj== "Guiyang") {return "Guiyang"}
else if (obj== "Jinan") {return "Jinan"}
else if (obj== "Hefei") {return "Hefei"}
else if (obj== "Fuzhou") {return "Fuzhou"}
else if (obj== "Nanjing") {return "Nanjing"}
Else{return obj}
}
Wind function
var windch=wind (Directionv)
function Wind (a) {
if (a>337 && a<=360) {return "North Wind"};
else if (a>=0 && a<=22) {return "North Wind"};
else if (a>22 && a<=67) {return "NE"};
else if (a>67 && a<=112) {return "Dongfeng"};
else if (a>112 && a<=157) {return "southeast"};
else if (a>157 && a<=202) {return "southerly"};
else if (a>202 && a<=247) {return "South-West Wind"};
else if (a>247 && a<=292) {return "westerly"};
else if (a>292 && a<=337) {return "Northwest Wind"};
}
Visibility function
Visibility=vis (VISIBILITYV)
function Vis (a) {
Return a/100
}
Convert weather to Chinese
var textch=ten2ch (TEXTV)
function ten2ch (obj) {
if (obj== "clear") {return "Sunny"}
else if (obj== "Sunny") {return "Sunny"}
else if (obj== "Partly cloudy") {return "Local cloud"}
else if (obj== "mostly clear") {return "Sunny"}
else if (obj== "mostly Sunny") {return "Small cloud"}
else if (obj== "Mostly cloudy") {return "cloudy"}
else if (obj== "cloudy") {return "cloud"}
else if (obj== "Sunny/wind") {return "Sunny Turn Cloud"}
else if (obj== "AM clouds/pm sun/wind") {return "cloud clears"}
else if (obj== "AM showers") {return "Morning Rain"}
Else{return obj}
}
Weather pictures
var weanum=weaimg (Codev)
function weaimg (obj) {
Return "}
Week replacement
function Dayen (obj) {
if (obj== "Sun") {return "Sunday"}
else if (obj== "Mon") {return "Monday"}
else if (obj== "Tue") {return "Tuesday"}
else if (obj== "Wed") {return "Wednesday"}
else if (obj== "Thu") {return "Thursday"}
else if (obj== "Fri") {return "Friday"}
else if (obj== "Sat") {return "Saturday"}
Else{return obj}
}
%>
<table width= "163" border= "0" align= "center" cellpadding= "0" cellspacing= "0" >
<tr>
<TD rowspan= "6" align= "Center" ><%=citych%><br/>
<%=weanum%><br/>
<%=textCH%></td>
<TD align= "Right" > Feeling:</td>
<TD align= "center" ><%=chillV%>°</td>
</tr>
<tr style= "Background-color: #E6F5FF" >
<TD align= "Right" > actual:</td>
<TD align= "center" ><%=tempV%>°</td>
</tr>
<tr>
<TD align= "Right" > Wind Direction:</td>
<TD align= "center" ><%=windCH%></td>
</tr>
<tr style= "Background-color: #E6F5FF" >
<TD align= "Right" > Wind speed:</td>
<TD align= "center" ><%=speedV%>Kph</td>
</tr>
<tr>
<TD align= "Right" > Humidity:</td>
<TD align= "center" ><%=humidityV%>%</td>
</tr>
<tr style= "Background-color: #E6F5FF" >
<TD align= "Right" > Visibility:</td>
<TD align= "center" ><%=visibility%>km</td>
</tr>
</table>
<table width= "163" border= "0" align= "center" cellpadding= "0" cellspacing= "0" >
<tr>
<TD colspan= "2" align= "center" class= "Time" ><%=lastV%></td>
</tr>
<tr>
<TD bgcolor= "#FFFFCC" > Sunrise:<%=sunrisev%></td>
<TD bgcolor= "#FFCC00" > Sunset:<%=sunsetv%></td>
</tr>
</table>
<table width= "163" border= "0" align= "center" cellpadding= "0" cellspacing= "0" >
<tr>
<%
for (var i=0; i<2; i++) {
var Dayv=attri (forecastnode,i, "Day")
var Datev=attri (forecastnode,i, "date")
var Lowv=attri (forecastnode,i, "low")
var Highv=attri (forecastnode,i, "high")
var Texttv=attri (forecastnode,i, "text")
var Codetv=attri (forecastnode,i, "code")
var Daych=dayen (DAYV)
var texttch=ten2ch (TEXTTV)
var weabmp=weaimg (Codetv)
var weatnum=weaimg (Codetv)
%>
<TD align= "center" ><%=daych%><br/><%=weabmp%><br/><%=texttch%><br/> The highest <%=highv%>°<br/> Minimum <%=lowV%>°</td>
<%
}
%>
</tr>
</table>