国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

xmlhttp組件獲取遠程文件并篩選出目標數據

2019-11-18 19:13:18
字體:
來源:轉載
供稿:網友

getfile.asp
<%
''利用xmlhttp組件獲取遠程文件保存到當前空間
''此是網站建設中的一個實例,遠程獲取一個網頁內容并篩選出相關的天氣數據,當然可以跳過文件本地存儲再獲取數據
''參考了xoyu的函數,在此感謝
fileurl="''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

''以上完成遠程存儲文件,以下只適用于對文本型文件的操作m.survivalescaperooms.com
set fso=server.createobject("scrset fileout=fso.opentextfile(server.mappath(filepath),1)
content=fileout.readall
set fileout=nothing
set fso=nothing
''response.write content

contentarr=split(content,"<td") ''根據內容進行篩選
for i=1 to ubound(contentarr)
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頁中引用顯示獲取內容
<script src="getfile.asp"></script>


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 磴口县| 余姚市| 文水县| 东乌珠穆沁旗| 陆川县| 胶南市| 德昌县| 丹阳市| 阳东县| 南靖县| 广东省| 深州市| 呼和浩特市| 大厂| 独山县| 内黄县| 甘洛县| 左贡县| 永昌县| 武乡县| 棋牌| 彭山县| 双辽市| 青川县| 江源县| 南昌县| 彭水| 新沂市| 铜鼓县| 图木舒克市| 文化| 林西县| 阜城县| 玉林市| 孝感市| 梅河口市| 柳州市| 霍林郭勒市| 东乡| 菏泽市| 盐亭县|