文章分类 | 软件分类 | 最新软件 | 杀毒软件 | 实用软件  | MTV下载  | 设为首页 |
  | 下载分类 | 最近更新
您的位置: 首页 >> 文章首页 >> 技术开发 >> XML 学院 >>  
XML 学院点击TOP10
·了解WEB页面工具语言XML五好处2006-2-9 16:29:48
·使用PHP DOM-XML创建和解析XML文件2006-2-5 14:16:30
·XML在语音合成中的应用2006-2-9 16:36:32
·制作虚线效果的水平线2006-2-10 11:43:03
·XML简易教程之三2006-2-9 16:30:35
·XSL简明教程5XSL的索引2006-2-9 16:29:31
·ADO数据与XML数据间的转换的类2006-2-9 16:29:15
·XSL简明教程2XSL转换2006-2-9 16:29:27
·为何XML对Web服务很重要2006-2-9 16:33:56
·使用xmldom在服务器端生成静态html页面2006-2-9 16:30:29
技术开发点击TOP10
·数据库升迁从sqlserver6.5到sqlserver20002006-2-9 17:36:12
·ASP生成JS调用的代码2006-2-9 9:06:53
·彻底终结浏览器Cahce页面的解决方案2006-2-5 13:31:26
·Javascript实例教程20 OLE Automation72006-2-9 16:53:32
·有关微软新一代开发技术ASP+的介绍2006-2-5 13:30:03
·MySQL Join详解2006-2-9 16:57:36
·ASP 中 Split 函数的实例2006-2-9 17:32:00
·使用视图控制用户对数据访问2006-2-9 17:33:51
·SQL Server 2000安装和基本框架2006-2-9 17:34:09
·怎样才能实现随机广告2006-2-5 13:19:42

 

采用XMLHTTP编写一个天气预报的程序
作者:我去下载           时间:2006-2-9 18:40:41


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

分页:
相关文章:
Copyright© 2005-2006 wqxz.com, All Rights Reserved. 购买虚拟主机请与本站联系