整理的网页中调用天气预报代码

第一种:
代码:
<iframe width="145" height="130" border="0" align="center" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" src="http://minisite.qq.com/Weather/news_new.html" allowTransparency="true"></iframe>

效果预览:
 

说明:这种适合于在网页的边栏插入。但一个缺点是,上面的4个城市是既定的,无法改成别的。插入时,选好网页上的位置,直接将左栏的源代码全部拷进去就行了
第二种:
代码:
<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>

效果预览:
 

说明:这种 也适合于在网页的边栏插入。上面的城市可以自定,比如厦门可改成别的。定制的方法是修改我代码中标红的数字,从1开始代表“香港”开始,每个数字都代表一个城市,厦门是287,具体要哪个城市自己找一下罢。
第三种:
代码:
<IFRAME ID='ifm2' WIDTH='260' HEIGHT='70' ALIGN='CENTER' MARGINWIDTH='0' MARGINHEIGHT='0' HSPACE='0' VSPACE='0' FRAMEBORDER='0' SCROLLING='NO' src="http://news.sina.com.cn/iframe/weather/130101.html"></iframe>

效果预览:

 
说明:这种适合于在网页的头栏插入。上面的城市可以自定,比如 石家庄可改成别的。定制的方法是修改我代码中标红的数字。具体各个城市对照的id表可在此下载:
城市名称及ID对照表
(请右键点击—>另存为)。
第四种:
代码:
<iframe width="469" height="218" border="0" align="center" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" src="http://appnews.qq.com/cgi-bin/news_weather_search?city=厦门" allowTransparency="true"></iframe>

效果预览:

 
说明:这种适合于在网页的正栏插入。上面的城市可以自定,比如厦门可改成别的。定制的方法是修改我代码中标红的 名称。这里比较简单,直接用汉字改就行了。比如是福州的,你就直接把“厦门”改成福州就行。
第五种:
代码:
<IFRAME ID='ifm1' WIDTH='405' HEIGHT='332' ALIGN='center' MARGINWIDTH='0' MARGINHEIGHT='0' HSPACE='0' VSPACE='0' FRAMEBORDER='0' SCROLLING='NO' SRC="http://weather.qq.com/24.htm"></IFRAME>

效果预览:

 
第六种(最新补充):
代码:
<iframe width=160 height=230 frameborder=0 scrolling=NO src=http://appnews.qq.com/cgi-bin/news_qq_search?city=南昌></iframe>

效果预览:

说明:这种适合于在网页的边栏插入。上面的城市可以自定,比如南昌可改成别的。定制的方法是修改我代码中标红的名称。这里比较简单,直接用汉字改就行了。比如是福州的,你就直接把“厦门”改成福州就行。

第七种

自动: <script langusge="javascript" src="http://dw8.cn/2006/tq/"></script>  

固定: <script langusge="javascript" src="http://dw8.cn/2006/tq/?c=北京"></script>
地名可以改,如改为“郑州”调出的就是郑州的天气!

第八种

觉得这个就蛮好的,没有必须要点的链接,如果要换颜色什么的,加格css就好了阿。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>

<body>
<b style="font:9pt/150%   tahoma;color:#f08; background:#eaeaea;"><script langusge="javascript" src="http://dw8.cn/2006/tq/"></script></b>
</body>
</html>

第九种

滚动的纯文字天气预报

<title>无标题文档</title>
</head>
<body>
<marquee width="220" height="12" direction="left" scrollamount="1" scrolldelay="20" onMouseOver="this.stop()" onMouseOut="this.start()">
       <font color="#000000" size="2">
       <script language=JavaScript src="http://61.153.52.132/huf/hu121.js"></script>
       </font>
       </marquee>

</body>
</html>

第十种

这种有点麻烦,但学会了很有用阿!

带静态采集的天气预报源代码
发布日期:2005-8-23 17:41:11 发表人:本站原创 点击:403


<%
'声明一个函数,用于读取远程文件
DateName = "在线天气预报:今天是"& Year(now)&"年"&month(now)&"月"&Day(now)&"日 "& WeekDayName(3,true) &"    温度是:"

function getHTTPPage(url)
dim Http
set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
set http=nothing
if err.number<>0 then err.Clear
end function

'声明一个函数,对读取的远程文件进行汉字转码
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function

Dim Url, Html, Str_start, Str_end

'要偷的网页的地址,你只需要从http://www.weathercn.com/找到你要偷取的页面就行
Url="http://www.weathercn.com/forecastn/forcast/forecastDetail.jsp?station_name=北京&station_id=54511&province=北京&district=北京"

Html = getHTTPPage(Url) '开始读取远程地址

'搜索要偷取的内容的开始位置
Str_start = instr(Html, "<td align=""center"" width=""108"" bgcolor=""#D4ECFA"">")
Str_start = instr(Html,"<td align=""center"" bgcolor=""#F1F8FA""   width=""107""><span class=""MAX"">")
'Str_start = instr(Str_start, Html, "<table width=""770"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"">")

'搜索要偷取的内容的结束位置
Str_end = instr(Str_start, Html, "</span></td>")

'截取内容
Html = Mid(Html, Str_start, Str_end - Str_start)

'修改宽度
Html = Replace(Html, "<table width=""770"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"">", "<table width=""760"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"">")
'过滤内容中的图片地址
Html = Replace(Html, "images/", "http://www.weathercn.com/forecastn/forcast/images/")
'修改宽度
Html = Replace(Html, "<table width=""770"" border=""0"" cellpadding=""0"" cellspacing=""0"">", "<table width=""760"" border=""0"" cellpadding=""0"" cellspacing=""0"">")
'修改宽度
Html = Replace(Html, "<table width=""739""   border=""0"" cellspacing=""0"" cellpadding=""0"">", "<table width=""729""   border=""0"" cellspacing=""0"" cellpadding=""0"">")
'输出偷取的内容

response.Write(DateName & html)
'response.Write Html



Html = getHTTPPage(Url) '开始读取远程地址

'搜索要偷取的内容的开始位置
Str_start = instr(Html, "</tr><tr>")
Str_start = instr(Html,"<td align=""center"" bgcolor=""#F1F8FA"" class=""pub12blue"" width=""107"">")
'Str_start = instr(Str_start, Html, "<table width=""770"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"">")

'搜索要偷取的内容的结束位置
Str_end = instr(Str_start, Html, "</td>")

'截取内容
Html = Mid(Html, Str_start, Str_end - Str_start)

'修改宽度
'Html = Replace(Html, "<table width=""770"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"">", "<table width=""760"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"">")
'过滤内容中的图片地址
Html = Replace(Html, "images/", "http://www.weathercn.com/forecastn/forcast/images/")
'修改宽度
Html = Replace(Html, "<table width=""770"" border=""0"" cellpadding=""0"" cellspacing=""0"">", "<table width=""760"" border=""0"" cellpadding=""0"" cellspacing=""0"">")
'修改宽度
Html = Replace(Html, "<table width=""739""   border=""0"" cellspacing=""0"" cellpadding=""0"">", "<table width=""729""   border=""0"" cellspacing=""0"" cellpadding=""0"">")
'输出偷取的内容
'response.Write(DateName)
response.Write("   风速:")
response.Write Html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值