pratie.com
Weather Check Source code (trimmed down)
view demo
<%
response.buffer = true
dim action:action = request("action")
dim locid:locid = request("locid")
%>
<form action="default.asp" method="post" name="weather" id="weather">
<input type="hidden" name="action" value="post" />
<input type="text" name="locid" value="<%=locid%>" maxlength="8" />
<input type="submit" name="submit" id="submit" value="Weather Check" />
</form>
<%
If action = "post" then
on error resume next
set xmlDoc = createObject("MSXML2.DOMDocument")
xmlDoc.async = False
xmlDoc.setProperty "ServerHTTPRequest", true
xmlDoc.load("http://xml.weather.yahoo.com/forecastrss?p=" & locid)
city = xmlDoc.selectSingleNode("//channel/yweather:location").Attributes.GetNamedItem("city").Text
region = xmlDoc.selectSingleNode("//channel/yweather:location").Attributes.GetNamedItem("region").Text
country = xmlDoc.selectSingleNode("//channel/yweather:location").Attributes.GetNamedItem("country").Text
concode = xmlDoc.selectSingleNode("//item/yweather:condition").Attributes.GetNamedItem("code").Text
contxt = xmlDoc.selectSingleNode("//item/yweather:condition").Attributes.GetNamedItem("text").Text
temp = xmlDoc.selectSingleNode("//item/yweather:condition").Attributes.GetNamedItem("temp").Text
fc = xmlDoc.selectSingleNode("//channel/yweather:units").Attributes.GetNamedItem("temperature").Text
link = xmlDoc.selectSingleNode("//channel/link").Text
set xmlDoc = nothing
if err then
if err.number = "424" then
response.write "<span style=""font-weight:bold; color:#c30"">Error:</span>" &_
"<strong>Please provide a valid US Zip Code or a valid Yahoo Location ID.</strong>" &_
"<br /><br />A Yahoo location ID can be found by searching for your city at" &_
" <a href=""http://weather.yahoo.com/"" target=""_blank"">Yahoo! Weather</a>." &_
" The end of the URL for your city should look something like: EIXX0014.html." &_
" Grab the 8 digit code that precedes the '.html', and paste that into the search box above."
end if
else
response.write "<div style=""font:bold 13px/18px arial"">" & city & ", "
if region <> "" then
response.write region
else
response.write country
end if
response.write "</div>" &_
"<img src=""http://us.i1.yimg.com/us.yimg.com/i/us/we/31/b/" & concode & ".gif"" alt=" & contxt & " width=""31"" height=""31"" />" &_
"<h1 class=""temp"">" & temp & "° " & fc & "</h1>" &_
contxt &_
"<br><a href=" & link & " target=""_blank"">View Full Forecast</a>"
end if
End If
%>