如何在ASP网页中加入一个天气预报链接?

xiaosong2008 2007-05-28 05:46:36
我想在我的ASP网页中调用一个天气预报,显示本地的天气预报信息,该如何实现?
我查阅了以前的资料,链接大都无法可用,有一个可用,可是太不准了,我想调用比较准确的比如中央气象台,或滕讯的等,该如何实现呢?
...全文
2226 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
kevinsum 2007-05-29
  • 打赏
  • 举报
回复
<iframe src="http://www.tianqi123.com/php/current_city.php?c0=F9DC68&c1=white&c2=FEFCE0&t1=red&bg=white&w=178&text=no" width=178 height=110 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no align=center id=url></iframe>

用这个吧~~~

直接IFRAME
windflow 2007-05-29
  • 打赏
  • 举报
回复
用我的吧,http://cnya10.com/blog/article.asp?id=44
最近刚完成的,返回XML数据,你可以很灵活的在前端处理
beyondjsq 2007-05-29
  • 打赏
  • 举报
回复
Function GetWeatherHTML()
Dim XmlDoc,XmlList,tempData,xmlData,MaxTemperature,MinTemperature,WeatherICO,tempNum,tempDate
Set XmlDoc = Server.CreateObject("Msxml.DOMDocument")
XmlDoc.async = false
XmlDoc.setProperty "ServerHTTPRequest", true
GetWeatherHTML = ""
if xmlDoc.load(WeatherFile) then
Set XmlList = xmlDoc.selectSingleNode("//dayf")
if not isNull(XmlList) then
if XmlList.childNodes.item(0).nodeName="lsup" then

tempData = XmlList.childNodes.item(0).text

tempNum = instr(1,tempData,"/")
tempDate = left(tempData,tempNum-1) & "月"
tempData = mid(tempData,tempNum+1)

tempNum = instr(1,tempData,"/")
tempDate = tempDate & left(tempData,tempNum-1) & "日"
tempData = mid(tempData,tempNum+1)

tempNum = instr(1,tempData," ")
tempDate = left(tempData,tempNum-1) & "年" & tempDate


if isDate(tempDate) then

if DateDiff("d",CDate(tempDate),now())=0 then
For i=1 To XmlList.childNodes.length
if XmlList.childNodes.item(i).nodeName="day" then
if XmlList.childNodes.item(i).getAttribute("d")="0" then
Set xmlData = XmlList.childNodes.item(i).childNodes
if not isNull(xmlData) then
MaxTemperature = xmlData.item(0).text
if IsNumeric(MaxTemperature) Then
MaxTemperature = (Clng(MaxTemperature)-32)*5\9
end if
MinTemperature = xmlData.item(1).text
if IsNumeric(MinTemperature) Then
MinTemperature = (Clng(MinTemperature)-32)*5\9
end if
WeatherICO = xmlData.item(4).childNodes.item(0).text
GetWeatherHTML = "<br><br><table width=" & 140 + MarginWidth & "><tr><td align=center>天气情况</td><td align=center>最低温度</td><td align=center>最高温度</td></tr><tr><td align=center><img src=""/PublicFunction/Weather/" & WeatherICO & ".gif"" border=0 align=absbottom></td><td align=center>" & MinTemperature & "℃</td><td align=center>" & MaxTemperature & "℃</td></tr></table>"
end if
Exit For
end if
end if
next
end if
end if
end if
end if
end if
end Function

'获取天气预报
Set fso = CreateObject("Scripting.FileSystemObject")
WeatherFile = Server.MapPath("/User_Data/Weather.XML")
if Not fso.FileExists(WeatherFile) Then
GetWeatherXML()
End If
if fso.FileExists(WeatherFile) Then
tempData = GetWeatherHTML()
if tempData="" Then
GetWeatherXML()
tempData = GetWeatherHTML()
end if
Response.Write tempData
end if
BoyHaXin 2007-05-29
  • 打赏
  • 举报
回复
subasan 2007-05-28
  • 打赏
  • 举报
回复
<!--此特效来源来互联网,由 kudaa.com 收集整理-->
<!--网页天气预报代码大全-->
<P>考虑到平时会用到各种形式的天气显示形式,所以将平时在网上搜集的和自己整理的天气代码放在这里 供参考(由于大部分效果使用的是框架调用别人的代码,所以当别人的网站修改了代码的时候有的效果可 能显示不出来需要到相关网站查看修改):</P>
<P><STRONG>名称</STRONG>:<FONT color=#ff0000>265天气根据IP自动获得当地的天气情况</FONT><BR><STRONG>代码</STRONG>:<iframe src="<A href="http://weather.265.com/weather.htm">http://weather.265.com/weather.htm</A>" width="168" height="54" frameborder="no" border="0" marginwidth="0&quoat; marginheight="0" scrolling="no"></iframe><BR><STRONG>效果</STRONG>:<BR><IFRAME border=0 marginWidth=0 marginHeight=0 src="http://weather.265.com/weather.htm" frameBorder=no width=168 scrolling=no height=54></IFRAME><BR><BR><STRONG>说明 </STRONG>:直接调用<BR></P><BR>
<P><STRONG>名称</STRONG>:<FONT color=#ff0000>QQ天气预报代码(一)</FONT><BR><STRONG>代码 </STRONG>:<iframe width="145" height="130" border="0" align="center" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" src="<A href="http://minisite.qq.com/Weather/news_new.html">http://minisite.qq.com/Weather/news_new.h tml</A>" allowTransparency="true"></iframe><BR><STRONG>效果 </STRONG>:<BR><IFRAME border=0 align=center marginWidth=0 marginHeight=0 src="http://minisite.qq.com/Weather/news_new.html" frameBorder=0 width=145 scrolling=no height=130 allowTransparency></IFRAME><BR><BR><STRONG>说明 </STRONG>:这种适合于在网页的边栏插入。但一个缺点是,上面的4个城市是既定的,无法改成别的。插 入时,选好网页上的位置,直接将左栏的源代码全部拷进去就行了<BR></P><BR>
<P><STRONG>名称</STRONG>:<FONT color=#ff0000>QQ天气预报代码(二)</FONT><BR><STRONG>代码 </STRONG>:<IFRAME ID='ifm2' WIDTH='189' HEIGHT='190' ALIGN='CENTER' MARGINWIDTH='0' MARGINHEIGHT='0' HSPACE='0' VSPACE='0' FRAMEBORDER='0' SCROLLING='NO' SRC='http://weather.qq.com/inc/ss258.htm'></IFRAME><BR><STRONG>效果 </STRONG>:<BR><IFRAME id=ifm2 align=center marginWidth=0 marginHeight=0 src="http://weather.qq.com/inc/ss258.htm" frameBorder=0 width=189 scrolling=no height=190></IFRAME><BR><BR><STRONG>说明 </STRONG>:这种 也适合于在网页的边栏插入。上面 的城市可以自定,比如厦门可改成别的。定制的方法是修改我代码中标红的数字,从1开始代表“香 港”开始,每个数字都代表一个城市,厦门是287,具体要哪个城市自己找一下罢。<BR></P><BR>
<P><STRONG>名称</STRONG>:<FONT color=#ff0000>新浪天气预报代码</FONT><BR><STRONG>代码 </STRONG>:<IFRAME ID='ifm2' WIDTH='260' HEIGHT='70' ALIGN='CENTER' MARGINWIDTH='0' MARGINHEIGHT='0' HSPACE='0' VSPACE='0' FRAMEBORDER='0' SCROLLING='NO' src="<A href='http://news.sina.com.cn/iframe/weather/130101.html"></iframe'>http://news.sina.com.cn/iframe/weather/130101.html"></iframe</A>><BR><STRONG>效果 </STRONG>:<BR><IFRAME id=ifm2 align=center marginWidth=0 marginHeight=0 src="http://news.sina.com.cn/iframe/weather/130101.html" frameBorder=0 width=260 scrolling=no height=70></IFRAME><BR><BR><STRONG>说明 </STRONG>:这种适合于在网页的头栏插入。上面的城市可以自定,比如 石家庄可改成别的。<BR></P><BR>
<P><STRONG>名称</STRONG>:<FONT color=#ff0000>QQ天气预报代码(三)</FONT><BR><STRONG>代码 </STRONG>:<iframe width="469" height="218" border="0" align="center" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" src="<A href="http://appnews.qq.com/cgi-bin/news_weather_search?city">http://appnews.qq.com/cgi-bin/news_weather_search?city</A>=厦门" allowTransparency="true"></iframe><BR><STRONG>效果 </STRONG>:<BR><IFRAME border=0 align=center marginWidth=0 marginHeight=0 src="http://appnews.qq.com/cgi-bin/news_weather_search?city=厦门" frameBorder=0 width=469 scrolling=no height=218 allowTransparency></IFRAME><BR><BR><STRONG>说明 </STRONG>:这种适合于在网页的正栏插入。上面的城市可以自定,比如厦门可改成别的。定制的方法是修改我代码中标红的 名称。这里比较简单,直接用汉字改就行了。比如是福州的,你就直接把“厦门”改成福州就行。<BR></P><BR>
<P><STRONG>名称</STRONG>:<FONT color=#ff0000>QQ天气预报代码(四)</FONT><BR><STRONG>代码 </STRONG>:<iframe width=160 height=230 frameborder=0 scrolling=NO src=http://appnews.qq.com/cgi-bin/news_qq_search?city=南昌></iframe><BR><STRONG>效果 </STRONG>:<BR><IFRAME id=ifm1 align=center marginWidth=0 marginHeight=0 src="http://weather.qq.com/24.htm" frameBorder=0 width=405 scrolling=no height=332></IFRAME><BR><BR><STRONG>说明 </STRONG>:直接调用<BR></P><BR>
<P><STRONG>名称</STRONG>:<FONT color=#ff0000>QQ天气预报代码(五)</FONT><BR><STRONG>代码 </STRONG>:<iframe src="<A href="http://appnews.qq.com/cgi-bin/news_qq_search?city">http://appnews.qq.com/cgi-bin/news_qq_search?city</A>=南昌" frameborder="0" width="160" scrolling="no" height="230"></iframe><BR><STRONG>效果 </STRONG>:<BR><IFRAME src="http://appnews.qq.com/cgi-bin/news_qq_search?city=南昌" frameBorder=0 width=160 scrolling=no height=230></IFRAME><BR><BR><STRONG>说明 </STRONG>:这种适合于在网页的边栏插入。上面的城市可以自定,比如南昌可改成别的。定制的方法是修改我代码中标红的名称。这里比较简单,直接用汉字改就行了。比如是福州的,你就直接把“厦门”改成福州就行<BR></P>
<P><BR></P>
</DIV>





来自 http://www.kudaa.com

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧