ASP源码
PHP源码
.NET源码
JSP源码
ge***le.asp
<%
''利用xmlhttp组件获取远程文件保存到当前空间
''此是网站建设中的一个实例,远程获取一个网页内容并筛选出相关的天气数据,当然可以跳过文件本地存储再获取数据
''参考了xoyu的函数,在此感谢
fileurl="http://www.hbqx.gov.cn/other/tqyb/inc_city_hb.asp"
dotloc=InStrRev(fileurl,".")
filepath="thistest"&mid(fileurl,dotloc) ''建立同类型文件名
''filepath="th***est.htm"
call saveRemoteFile(filepath,fileurl)
sub SaveRemoteFile(LocalFileName,RemoteFileUrl)
dim Ads,Retrieval,GetRemoteData
Set Retrieval = Se***r.CreateObject("Mi***soft.XMLHTTP")
With Retrieval
.Open "Get", RemoteFileUrl, False, "", ""
.Send
GetRemoteData = .ResponseBody
'' GetDetail = .ResponseText ''对文本型文件可直接获取内容,但不能支持中文,不知道如何解决
End With
Set Retrieval = Nothing
''RE***NSE.WRITE GetDetail
Set Ads = Se***r.CreateObject("Ad***.Stream") ''生成对应文件
With Ads
.Type = 1
.Open
.Write GetRemoteData
.SaveToFile se***r.MapPath(LocalFileName),2
.Cancel()
.Close()
End With
Set Ads=nothing
end sub
''以上完成远程存储文件,以下只适用于对文本型文件的操作www.downcodes.com
set fs***erver.createobject("sc***ting.filesystemobject") ''读取文件内容
set fi***ut=fso.opentextfile(se***r.mappath(filepath),1)
co***nt=fileout.readall
set fileout=nothing
set fso=nothing
''re***nse.write content
contentarr=split(content,"
在另一个htm页中引用显示获取内容