远程文件获取与数据筛选_xmlhttp组件获取远程文件并筛选出目标数据
扫描二维码随身看资讯
使用手机 二维码应用 扫描右侧二维码,您可以
1. 在手机上细细品读~
2. 分享给您的微信好友或朋友圈~
getfile.asp
<%
利用xmlhttp组件获取远程文件保存到当前空间
此是网站建设中的一个实例,远程获取一个网页内容并筛选出相关的天气数据,当然可以跳过文件本地存储再获取数据
参考了xoyu的函数,在此感谢
fileurl=http://www.hbqx.gov.cn/other/tqyb/inc_city_hb.asp
dotloc=InStrRev(fileurl,.)
filepath=thistest&mid(fileurl,dotloc) 建立同类型文件名
filepath=thistest.htm
call saveRemoteFile(filepath,fileurl)
sub SaveRemoteFile(LocalFileName,RemoteFileUrl)
dim Ads,Retrieval,GetRemoteData
Set Retrieval = Server.CreateObject(Microsoft.XMLHTTP)
With Retrieval
.Open Get, RemoteFileUrl, False, ,
.Send
GetRemoteData = .ResponseBody
GetDetail = .ResponseText 对文本型文件可直接获取内容,但不能支持中文,不知道如何解决
End With
Set Retrieval = Nothing
RESPONSE.WRITE GetDetail
Set Ads = Server.CreateObject(Adodb.Stream) 生成对应文件
With Ads
.Type = 1
.Open
.Write GetRemoteData
.SaveToFile server.MapPath(LocalFileName),2
.Cancel()
.Close()
End With
Set Ads=nothing
end sub
以上完成远程存储文件,以下只适用于对文本型文件的操作
set fso=server.createobject(scripting.filesystemobject) 读取文件内容
set fileout=fso.opentextfile(server.mappath(filepath),1)
content=fileout.readall
set fileout=nothing
set fso=nothing
response.write content
contentarr=split(content,
if instr(contentarr(i),恩施) then thisloc=i
next
dim xu(5)
for j=0 to 4
con1=contentarr(thisloc+j)
start1=instr(con1,>)
con1=right(con1,len(con1)-start1)
stop1=instr(con1,<)
con1=left(con1,stop1-1)
str=str&contentarr(thisloc+j)
xu(j)=trim(con1)
next
if xu(1)<> then
response.write document.write(恩施州未来24小时天气预报:&xu(1)&,最低温度&xu(2)&摄氏度,最高温度&xu(3)&摄氏度,风向:&xu(4)&.--武汉中心气象台发布);
else
response.write document.write(暂未发布);
end if
response.write server.htmlencode(str)
%>
在另一个htm页中引用显示获取内容
- 1 远程文件获取与数据筛选_xmlhttp组件获取远程文件并筛选出目标数据
- 2 利用XMLHTTP 从其他页面获取数据_网络数据获取技术
- 3 XML Schema学习笔记_XML Schema学习指南
- 4 aspx安全漏洞防御_禁止跨站读取IIS信息cmd命令执行
- 5 Microsoft JET Database Engine 错误 80004005 错误解决办法_Access数据库错误修复
- 6 Android设备检测
- 7 ASP.NET 服务器应用程序不可用解决方法_IIS 注册问题排查
- 8 应用程序中的服务器错误及解决方法_应用程序服务器错误处理指南
- 9 ASP Cookies方法_ASP Cookie设置指南
- 10 Win8 RP8000 .NET Framework 3.5 安装指南_安装方法
-
PHP_Session问题集锦及解决方法_PHP Session 优化与调试
PHP_session_问题_解决方法_集锦
-
安装 .Net Framework 4 安装失败解决方案_解决信任关系错误
安装 .Net Framework4,怎么安装都不行,老是提示“安装未成功”、“


