濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > 利用xmlhttp和adodb.stream加緩存技術(shù)下載遠(yuǎn)程Web文件

利用xmlhttp和adodb.stream加緩存技術(shù)下載遠(yuǎn)程Web文件

熱門(mén)標(biāo)簽:自動(dòng)外呼系統(tǒng)怎么防止封卡 客服外呼系統(tǒng)呼叫中心 vue 地圖標(biāo)注拖拽 電話(huà)機(jī)器人銷(xiāo)售公司嗎 土地證宗地圖標(biāo)注符號(hào) 電話(huà)機(jī)器人案例 保定電銷(xiāo)機(jī)器人軟件 成都銷(xiāo)售外呼系統(tǒng)公司 鎮(zhèn)江云外呼系統(tǒng)怎么樣

%
'----------遠(yuǎn)程獲取內(nèi)容,并將內(nèi)容存在本地電腦上,包括任何文件!----------
'---------------利用xmlhttp和adodb.stream-----------------
'On Error Resume Next
'-------------------------------定義輸出格式-----------------------------
path=request("path")
if path ="" then
path="http://pcqc.86516.com/index.asp"
'這里定義的網(wǎng)址是百度,,注意一定要有文件后綴
end if

sPath = Path
if left(lcase(path),7) > "http://" then
'-------------如果前面沒(méi)有http就是本地文件,交給LocalFile處理------------
LocalFile(path)
else
'--------------------否則為遠(yuǎn)程文件,交給RemoteFile處理------------------
RemoteFile(Path)
end if
'Response.Write err.Description
'--------------處理函數(shù)-----------

sub LocalFile(Path)
'-------------------如果為本地文件則簡(jiǎn)單的跳轉(zhuǎn)到該頁(yè)面-------------------
'Response.Redirect Path
Response.write "發(fā)生錯(cuò)誤!"
End Sub
Sub RemoteFile(sPath)
'-------------------------處理遠(yuǎn)程文件函數(shù)------------------------------
FileName = GetFileName(sPath)
'-------------GetFileName為把地址轉(zhuǎn)換為合格的文件名過(guò)程-------------
FileName = Server.MapPath("Cache/" FileName)
Set objFso = Server.CreateObject("Scripting.FileSystemObject")
'Response.Write fileName
if objFso.FileExists(FileName) Then
'--------------檢查文件是否是已經(jīng)訪問(wèn)過(guò),如是,則簡(jiǎn)單跳轉(zhuǎn)------------
Response.Redirect "cache/" GetFileName(path)
Else
'----------------否則的話(huà)就先用GetBody函數(shù)讀取----------------------
'Response.Write Path
t = GetBody(Path)
'-----------------用二進(jìn)制方法寫(xiě)到瀏覽器上--------------------------
Response.BinaryWrite t
Response.Flush
'-----------------輸出緩沖------------------------------------------
SaveFile t,GetFileName(path)
'------------------將文件內(nèi)容緩存到本地路徑,以待下次訪問(wèn)-----------
End if
Set objFso = Nothing
End Sub

Function GetBody(url)
'-----------------------本函數(shù)為遠(yuǎn)程獲取內(nèi)容的函數(shù)---------------------
'on error resume next
'Response.Write url
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
'----------------------建立XMLHTTP對(duì)象-----------------------------
With Retrieval
.Open "Get", url, False, "", ""
'------------------用Get,異步的方法發(fā)送-----------------------
.Send
'GetBody = .ResponseText
GetBody = .ResponseBody
'------------------函數(shù)返回獲取的內(nèi)容--------------------------
End With
Set Retrieval = Nothing
'response.Write err.Description
End Function

Function GetFileName(str)
'-------------------------本函數(shù)為合格化的文件名函數(shù)-------------------
str = Replace(lcase(str),"http://","")
str = Replace(lcase(str),"http://","/")
str = Replace(str,"?","")
str = Replace(str,"","")
str = Replace(str,"/","")
str = replace(str,vbcrlf,"")
GetFileName = str
End Function

sub SaveFile(str,fName)
'-------------------------本函數(shù)為將流內(nèi)容存盤(pán)的函數(shù)-------------------
'on error resume next
Set objStream = Server.CreateObject("ADODB.Stream")
'--------------建立ADODB.Stream對(duì)象,必須要ADO 2.5以上版本---------
'objStream.Type = adTypeBinary
objStream.Type = 1
'-------------以二進(jìn)制模式打開(kāi)-------------------------------------
objStream.Open
objstream.write str
'--------------------將字符串內(nèi)容寫(xiě)入緩沖--------------------------
'response.Write fname
'路徑注意
objstream.SaveToFile "E:\webroot\pcqc\vip\UploadFile\cache\"fName,2
'objstream.SaveToFile "d:\cache\" fName,adSaveCreateOverWrite
'--------------------將緩沖的內(nèi)容寫(xiě)入文件--------------------------
'response.BinaryWrite objstream.Read
objstream.Close()
set objstream = nothing
'-----------------------關(guān)閉對(duì)象,釋放資源-------------------------
'response.Write err.Description
End sub

function saveimage(from,tofile)
dim geturl,objStream,imgs
geturl=trim(from)
imgs=gethttppage(geturl)'取得圖片的具休內(nèi)容的過(guò)程
Set objStream = Server.CreateObject("ADODB.Stream")'建立ADODB.Stream對(duì)象,必須要ADO 2.5以上版本
objStream.Type =1'以二進(jìn)制模式打開(kāi)
objStream.Open
objstream.write imgs'將字符串內(nèi)容寫(xiě)入緩沖
objstream.SaveToFile server.mappath(tofile),2'-將緩沖的內(nèi)容寫(xiě)入文件
objstream.Close()'關(guān)閉對(duì)象
set objstream=nothing
end function
%>

您可能感興趣的文章:
  • 用ASP VBS xmlhttp adodbstream下載和保存圖片的代碼
  • 利用MSXML2.XmlHttp和Adodb.Stream采集圖片
  • 使用asx3m與xstream配合解決flex與java利用httpservice傳遞xml數(shù)據(jù)問(wèn)題
  • php中突破基于HTTP_REFERER的防盜鏈措施(stream_context_create)
  • php錯(cuò)誤提示failed to open stream: HTTP request failed!的完美解決方法
  • HttpResponse的Output與OutputStream、Filter關(guān)系與區(qū)別介紹
  • 利用stream實(shí)現(xiàn)一個(gè)簡(jiǎn)單的http下載器

標(biāo)簽:天津 內(nèi)江 麗江 重慶 成都 公主嶺 懷化 臺(tái)灣

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《利用xmlhttp和adodb.stream加緩存技術(shù)下載遠(yuǎn)程Web文件》,本文關(guān)鍵詞  利用,xmlhttp,和,adodb.stream,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《利用xmlhttp和adodb.stream加緩存技術(shù)下載遠(yuǎn)程Web文件》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于利用xmlhttp和adodb.stream加緩存技術(shù)下載遠(yuǎn)程Web文件的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    清涧县| 永平县| 莫力| 奉化市| 陆丰市| 洛南县| 肥乡县| 宕昌县| 南部县| 枣阳市| 信丰县| 靖州| 吴忠市| 贵南县| 大冶市| 邢台县| 大田县| 西畴县| 梧州市| 贵德县| 若尔盖县| 靖远县| 芜湖县| 五莲县| 临清市| 凤庆县| 福泉市| 澄江县| 灵石县| 固安县| 城步| 梅州市| 金门县| 盐山县| 苏尼特左旗| 社旗县| 松溪县| 玛纳斯县| 锦州市| 伊通| 嫩江县|