中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > Web开发 > Asp > 综合文章
获取天气预报信息
作者:佚名 时间:2004-10-06 10:44 出处:互连网 责编:chinaitpower
              摘要:获取天气预报信息
<form method=post action="weareport.asp">
城市:<input name=city value='哈尔滨'><br/>
地区:<input name=area value='东北'><br/>
省份:<input name=province value='黑龙江'><br/>
<input type=submit value='查看'>
</form>
<%
if request("city")<>"" then
city=request("city")
area=request("area")
province=request("province")
contents=getHTTPpage("http://www.cma.gov.cn/netcenter_news/qxyb/city/index.php?city="&city&"&province="&province&"&area="&area)
startPos=CutedPage(contents,"<!--天气预报开始-->",1)
endPos=CutedPage(contents,"<!--天气预报结束-->",0)
contents=mid(contents,startPos,endPos-startPos)
contents=replace(contents,"src=http://www.webasp.net/article/17//","src=http://www.cma.gov.cn/")
contents=replace(contents,"src=..","src=http://www.cma.gov.cn/netcenter_news/qxyb/city/..")
response.write contents
end if

function CutedPage(scontent,str,mode)
if scontent="" then exit function
pos=instr(scontent,str)
if pos>=0 then
if mode=0 then
CutedPage=pos
else
CutedPage=pos+len(str)
end if
else
Cutepage=len(scontent)
end if
end function

Function Bytes2Bstr2(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
Bytes2Bstr2 = objstream.ReadText
objstream.Close
set objstream = nothing
End Function

function getHTTPPage(url)
on error resume next
dim http
set http=Server.createobject("Microsoft.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then exit function
getHTTPPage=bytes2BSTR2(Http.responseBody,"GB2312")
set http=nothing
if err.number<>0 then err.Clear
end function
%>


关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有