人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

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

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

更新時間:2022-08-16 文章作者:未知 信息來源:網絡 閱讀次數:

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

''以上完成遠程存儲文件,以下只適用于對文本型文件的操作www.knowsky.com
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,"<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>

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 普陀区| 崇阳县| 康定县| 云梦县| 翼城县| 垣曲县| 武宁县| 林芝县| 鞍山市| 张家港市| 江孜县| 石河子市| 大埔县| 灵山县| 南投市| 库车县| 泽州县| 吉木萨尔县| 米脂县| 鲁山县| 绥化市| 承德市| 东莞市| 登封市| 成安县| 库尔勒市| 平乡县| 水城县| 铁岭县| 广汉市| 讷河市| 城口县| 洛南县| 卢氏县| 乐亭县| 兴城市| 阳原县| 柳河县| 额尔古纳市| 南木林县| 甘南县|