找回密码
 注册会员

扫一扫,访问微社区

QQ登录

只需一步,快速开始

立即体验天翼云服务器(质量靠谱V3.6版本中需要设置的地方汇总点此领幸运券买阿里云优惠多
查看: 7202|回复: 3

用ASP+XMLHTTP编写天气预报程序

[复制链接]

9

主题

42

回帖

430

积分

正式会员

积分
430
发表于 2006-5-3 22:22:23 | 显示全部楼层 |阅读模式
<A>本人就职于一个本地门户网站,每天网站上的天气都得更新。久而久之感到相当麻烦,于是写了一个定时的新闻小偷,帖出来大家参考一下系统要求: 支持FSO, 服务器UDP TCP/IP 没有屏蔽。 <BR><BR>  下面是小偷的内容:<BR><BR>FileName TianQi.asp<BR>Write By Niaoked QQ408611119<BR>www.knowsky.com<BR><%<BR> if hour(now)=9 and minute(now)<30 then<BR>  getCategories()<BR> end if <BR> Function getCategories()<BR>  on error resume next<BR>  Dim oXMLHTTP ' As Object<BR>  Dim oCategories ' As Object<BR>  Dim BodyText<BR>  Dim Pos,Pos1<BR>  Set oXMLHTTP = CreateObject("Microsoft.XMLHTTP")<BR>  '--- set the XMLHTTP call and issue send (no parm as category <BR>  '--- is included in URL<BR>  oXMLHTTP.open "GET","http://weather.china.com.cn/travel_gntq.php?cityid=56196;cityname=绵阳",False '这个地方换成你自己的地址<BR>  oXMLHTTP.send <BR>  '--- load the response into the Categories data island <BR>  BodyText=oXMLHTTP.responsebody<BR>  BodyText=BytesToBstr(BodyText,"gb2312")<BR>  Pos=Instr(BodyText,"<body")<BR>  pos1=Instr(BodyText,"</body>")<BR>  BodyText=mid(BodyText,pos,pos1)<BR>  BodyText=split(BodyText,"<table")<BR>  Pos=Instr(BodyText(4),"<tr")<BR>  pos1=Instr(BodyText(4),"</tr>")<BR>  Body=mid(BodyText(4),pos,len(BodyText(4))-pos)<BR>  body=split(body,"</table>")<BR>  body1=split(replace(replace(replace(body(0),"<br>",""),"</td>",""),"</tr>",""),"天气")<BR>  for i= 1 to ubound(body1)<BR>   body3=split(body1(i),"<td")<BR>   weather=weather ; "document.write("""; i;"$" ; "天气" ; HTMLEncode(trim(body3(0))) ; """);" ; vbcrlf<BR>  next<BR>  weather=replace(weather,"1$","<FONT color=#ffffff>【今天】</FONT>")<BR>  weather=replace(weather,"2$","<FONT color=#ffffff>【明天】</FONT>")<BR>  weather=replace(weather,"3$","<FONT color=#ffffff>【后天】</FONT>")<BR>  Set fs = CreateObject("Scripting.FileSystemObject")<BR>  Set f = fs.CreateTextFile(request.ServerVariables("APPL_PHYSICAL_PATH"); "tq.js", True)<BR>  f.write("document.write('绵阳天气预报:');" ;vbcrlf ; replace(weather,"<BR>",""))<BR>  f.close<BR>  Set f = nothing<BR>  Set fs = nothing<BR>  response.write "绵阳天气预报:"; weather<BR>  Set oXMLHTTP = Nothing <BR>  if err.number<>0 then<BR>   response.write "出错了,错误描述:";err.description ; "<br>错误来源" err.source<BR>   response.End()<BR>  end if<BR> End Function <BR></A><A>Function BytesToBstr(body,Cset)<BR>  dim objstream<BR>  set objstream = Server.CreateObject("adodb.stream")<BR>  objstream.Type = 1<BR>  objstream.Mode =3<BR>  objstream.Open<BR>  objstream.Write body<BR>  objstream.Position = 0<BR>  objstream.Type = 2<BR>  objstream.Charset = Cset<BR>  BytesToBstr = objstream.ReadText <BR>  objstream.Close<BR>  set objstream = nothing<BR> End Function<BR> Public Function HTMLEncode(fString)<BR>  If Not IsNull(fString) Then<BR>   fString = replace(fString, ">", ">")<BR>   fString = replace(fString, "<", "<")<BR>   fString = Replace(fString, CHR(32), " ") ';nbsp;<BR>   fString = Replace(fString, CHR(9), " ") ';nbsp;<BR>   fString = Replace(fString, CHR(34), """)<BR>   fString = Replace(fString, CHR(39), "'") '单引号过滤<BR>   fString = Replace(fString, CHR(13), "")<BR>   fString = Replace(fString, CHR(10) ; CHR(10), "</P><P> ")<BR>   fString = Replace(fString, CHR(10), "<BR> ")<BR>   HTMLEncode = fString<BR>  End If<BR> End Function<BR>%> <BR></A>
回复

使用道具 举报

495

主题

2663

回帖

20万

积分

管理员

积分
207527

社区居民新人进步

发表于 2006-5-4 21:54:42 | 显示全部楼层
<>没人支持俺.俺自己支持,呵呵</P>
十一休了整整13天,嘉缘福利好,没办法
回复 支持 反对

使用道具 举报

3

主题

20

回帖

0

积分

限制会员

积分
0
发表于 2009-3-31 12:24:06 | 显示全部楼层
来了来了
只是晚了两年,,没事,还是支持!!哈哈
http://www.16tom.com 一路通免费电影网
回复 支持 反对

使用道具 举报

0

主题

22

回帖

0

积分

限制会员

积分
0
发表于 2009-5-10 13:09:20 | 显示全部楼层
好像太长了
锦报招聘网www.13580job.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

QQ|Archiver|手机版|小黑屋|嘉缘软件官网 ( 沪ICP备12042403号-2 )

GMT+8, 2025-4-12 22:18 , Processed in 0.079547 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表