狠狠色丁香婷婷综合尤物/久久精品综合一区二区三区/中国有色金属学报/国产日韩欧美在线观看 - 国产一区二区三区四区五区tv

LOGO OA教程 ERP教程 模切知識(shí)交流 PMS教程 CRM教程 開(kāi)發(fā)文檔 其他文檔  
 
網(wǎng)站管理員

遠(yuǎn)程獲取類(lèi)Asp xmlHttp

admin
2013年11月28日 11:39 本文熱度 5308

這個(gè)class主要用于操作asp中的xmlhttp。

首先是類(lèi)定義 Cls_AspHttp.asp:
<%
''=================================================================
''飛揚(yáng)遠(yuǎn)程獲取類(lèi)(AspHttp) 1.0.1 Bate1
'' By 奔騰的心
'' 2006-04-19
''=================================================================
Class FlyCms_AspHttp
Public oForm,oXml,Ados
Public strHeaders
Public sMethod
Public sUrl
Public sReferer
Public sSetCookie
Public sLanguage
Public sCONTENT
Public sAgent
Public sEncoding
Public sAccept
Public sData
Public sCodeBase
Private slresolveTimeout,slconnectTimeout,slsendTimeout,slreceiveTimeout
'' ============================================
'' 類(lèi)模塊初始化
'' ============================================
Private Sub Class_Initialize()
oForm = ""
Set oXml = Server.CreateObject("MSXML2.ServerXMLHTTP")
set Ados = Server.CreateObject("Adodb.Stream")
slresolveTimeout = 20000 '' 解析DNS名字的超時(shí)時(shí)間,20秒
slconnectTimeout = 20000 '' 建立Winsock連接的超時(shí)時(shí)間,20秒
slsendTimeout = 30000 '' 發(fā)送數(shù)據(jù)的超時(shí)時(shí)間,30秒
slreceiveTimeout = 30000 '' 接收response的超時(shí)時(shí)間,30秒
End Sub

'' ============================================
'' 返回版本信息
'' ============================================
Public Property Get Version
Version = "飛揚(yáng)asphttp類(lèi)1.0.0"
End Property
'' ============================================
'' 解析DNS名字的超時(shí)時(shí)間
'' ============================================
Public Property Let lresolveTimeout(LngSize)
If IsNumeric(LngSize) Then
slresolveTimeout = Clng(LngSize)
End If
End Property
'' ============================================
'' 建立Winsock連接的超時(shí)時(shí)間
'' ============================================
Public Property Let lconnectTimeout(LngSize)
If IsNumeric(LngSize) Then
slconnectTimeout = Clng(LngSize)
End If
End Property
'' ============================================
'' 發(fā)送數(shù)據(jù)的超時(shí)時(shí)間
'' ============================================
Public Property Let lsendTimeout(LngSize)
If IsNumeric(LngSize) Then
slsendTimeout = Clng(LngSize)
End If
End Property
'' ============================================
'' 接收response的超時(shí)時(shí)間
'' ============================================
Public Property Let lreceiveTimeout(LngSize)
If IsNumeric(LngSize) Then
slreceiveTimeout = Clng(LngSize)
End If
End Property
'' ============================================
'' Method
'' ============================================
Public Property Let Method(strMethod)
sMethod = strMethod
End Property
'' ============================================
'' 發(fā)送url
'' ============================================
Public Property Let Url(strUrl)
sUrl = strUrl
End Property
'' ============================================
'' Data
'' ============================================
Public Property Let Data(strData)
sData = strData
End Property
'' ============================================
'' Referer
'' ============================================
Public Property Let Referer(strReferer)
sReferer = strReferer
End Property
'' ============================================
'' SetCookie
'' ============================================
Public Property Let SetCookie(strCookie)
sSetCookie = strCookie
End Property
'' ============================================
'' Language
'' ============================================
Public Property Let Language(strLanguage)
sLanguage = strLanguage
End Property
'' ============================================
'' CONTENT-Type
'' ============================================
Public Property Let CONTENT(strCONTENT)
sCONTENT = strCONTENT
End Property
'' ============================================
'' User-Agent
'' ============================================
Public Property Let Agent(strAgent)
sAgent = strAgent
End Property
'' ============================================
'' Accept-Encoding
'' ============================================
Public Property Let Encoding(strEncoding)
sEncoding = strEncoding
End Property
'' ============================================
'' Accept
'' ============================================
Public Property Let Accept(strAccept)
sAccept = strAccept
End Property
'' ============================================
'' CodeBase
'' ============================================
Public Property Let CodeBase(strCodeBase)
sCodeBase = strCodeBase
End Property
'' ============================================
'' 建立數(shù)據(jù)傳送對(duì)向!
'' ============================================
Public Function AddItem(Key, Value)
On Error Resume Next
Dim TempStr
If oForm = "" Then
oForm = Key + "=" + Server.URLEncode(Value)
Else
oForm = oForm + "&" + Key + "=" + Server.URLEncode(Value)
End If
End Function
'' ============================================
'' 發(fā)送數(shù)據(jù)并取回遠(yuǎn)程數(shù)據(jù)
'' ============================================
Public Function HttpGet()
Dim sReturn
With oXml
.setTimeouts slresolveTimeout,slconnectTimeout,slsendTimeout,slreceiveTimeout
.Open sMethod,sUrl,False
If sSetCookie<>"" Then
.setRequestHeader "Cookie", sSetCookie ''設(shè)定Cookie
End If
If sReferer<>"" Then
.setRequestHeader "Referer", sReferer ''設(shè)定頁(yè)面來(lái)源
Else
.setRequestHeader "Referer", sUrl
End If
If sLanguage<>"" Then
.setRequestHeader "Accept-Language", sLanguage ''設(shè)定語(yǔ)言
End If
.setRequestHeader "Content-Length",Len(sData) ''設(shè)定數(shù)據(jù)長(zhǎng)度
If sCONTENT<>"" Then
.setRequestHeader "CONTENT-Type",sCONTENT ''設(shè)定接受數(shù)據(jù)類(lèi)型
End If
If sAgent<>"" Then
.setRequestHeader "User-Agent", sAgent ''設(shè)定瀏覽器
End If
If sEncoding<>"" Then
.setRequestHeader "Accept-Encoding", sEncoding ''設(shè)定gzip壓縮
End If
If sAccept<>"" Then
.setRequestHeader "Accept", sAccept ''文檔類(lèi)型
End If
.Send sData ''發(fā)送數(shù)據(jù)
While .readyState <> 4
.waitForResponse 1000
Wend
strHeaders = .getAllResponseHeaders()
If sCodeBase<>"" Then
sReturn = bytes2BSTR(.responseBody)
Else
sReturn = .responseBody
End If
End With
HttpGet = sReturn
End Function
'' ============================================
'' 處理二進(jìn)制數(shù)據(jù)
'' ============================================
Private Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
'' ============================================
'' 類(lèi)模塊注銷(xiāo)
'' ============================================
Private Sub Class_Terminate
oForm = ""
Set oXml = Nothing
Set Ados = Nothing
End Sub
End Class
%>


function.asp 調(diào)用的代碼: (簡(jiǎn)化了代碼的書(shū)寫(xiě))
<%
''調(diào)試代碼
Sub Re1(Str)
Response.Write Str
Response.End
End Sub

Sub Rw(Str)
Response.Write Str & vbCrLf
Response.Flush
End Sub

Function HttpGet(lresolveTimeout,lconnectTimeout,lsendTimeout,lreceiveTimeout,Method,Url,Referer,Data,SetCookie,Language,CONTENT,Agent,Encoding,Accept,CodeBase)
DoGet.lresolveTimeout = lresolveTimeout
DoGet.lconnectTimeout = lconnectTimeout
DoGet.lsendTimeout = lsendTimeout
DoGet.lreceiveTimeout = lreceiveTimeout
DoGet.Method = Method
DoGet.Url = Url
DoGet.Referer = Referer
DoGet.Data = Data
DoGet.SetCookie = SetCookie
DoGet.Language = Language
DoGet.CONTENT = CONTENT
DoGet.Agent = Agent
DoGet.Encoding = Encoding
DoGet.Accept = Accept
DoGet.CodeBase = CodeBase
HttpGet = DoGet.HttpGet()
End Function

'' ============================================
'' 取得cookie頭
'' ============================================
Function GetCookie(ByVal strHead, ByVal sBound)
If strHead = "" Then
GetCookie = ""
Exit Function
End If
Dim strCookie, iCookie, bNum
strCookie = strHead

If strCookie <> "" And InStr(strCookie, "Set-Cookie") > 0 Then
strCookie = Replace(strCookie, "Set-Cookie: ", "〔")
strCookie = Replace(strCookie, ";", "〕")
Patrn = "〔[^〕]+〕"
strCookie = RegExpSearch(Patrn, strCookie, 0, "`")
strCookie = Replace(strCookie, "〔", "")
strCookie = Replace(strCookie, "〕", "")
strCookie = Split(strCookie, "`")
bNum = sBound
If bNum=-1 Then
For I=0 To UBound(strCookie)
If iCookie = "" Then
iCookie = strCookie(i)
Else
iCookie = iCookie & "; " & strCookie(i)
End If
Next
Else
If bNum > UBound(strCookie) Then
bNum = UBound(strCookie)
End If
iCookie = strCookie(bNum)
End If
End If
GetCookie = iCookie
End Function

'' ============================================
'' 按照指定的正則表達(dá)式返回字符
'' ============================================
Function RegExpSearch(Patrn, Str, sType, Spacer)
Dim RegEx, Match, Matches, RetStr, i
i = 0
Set RegEx = New RegExp
RegEx.Pattern = Patrn
RegEx.IgnoreCase = True
RegEx.Global = True
Set Matches = RegEx.Execute(Str)
For Each Match In Matches
i = i + 1
If sType = 0 Then
RetStr = RetStr & Match.Value
If i < Matches.Count Then RetStr = RetStr & Spacer
Else
RetStr = RetStr & Match.Value
If i < Matches.Count Then RetStr = RetStr & Spacer
If sType = i Then Exit For
End If
Next
RegExpSearch = RetStr
End Function


''*****************************************************************
'' function(私有)
'' 作用 :利用流保存文件
''*****************************************************************
Function SaveFiles(ByVal GetUrl, ByVal ToFile, ByVal sCookie, ByVal Agent, ByVal SaveShow)
Dim Datas, dSize
GetUrl = Replace(GetUrl, "\", "/")
Datas = HttpGet(10000, 10000, 20000, 20000, "GET", GetUrl, "", "", sCookie, "zh-cn", "", Agent, "", "*/*", "")
iSize = LenB(Datas)
dSize = FormatNumber(iSize / 1024, 3)
If iSize > 1 Then
Set Ados = Server.CreateObject("ADODB.Stream")
Ados.Type = 1
Ados.Mode = 3
Ados.Open
Ados.Write Datas
Ados.SaveToFile Server.MapPath(ToFile), 2
Ados.Close
Set Ados = Nothing
SaveFiles = True
If SaveShow = 1 Then
Response.Write "保存成功:<font color=red>" & dSize & "</font>Kb"
End If
Else
SaveFiles = False
If SaveShow = 1 Then
Response.Write "保存失敗:<font color=red>文件大小" & iSize & "K,小于1K</font>"
End If
End If
End Function
'' ============================================
'' 檢測(cè)文件夾是否存在 如果不存在就自動(dòng)創(chuàng)建多級(jí)文件夾
'' ============================================
Function CreatePath(strPath)
Dim fldr, FristStr
strPath = Replace(strPath, "\", "/")
strPath = Replace(strPath, Chr(0), "")
strPath = Replace(strPath, "http://", "/")
If Left(strPath, 1) = "/" Then
FristStr = "/"
strPath = Right(strPath, Len(strPath) - 1)
Else
FristStr = ""
strPath = strPath
End If
If Right(strPath, 1) = "/" Then
strPath = Left(strPath, Len(strPath) - 1)
Else
strPath = strPath
End If
GetNewsFold = Split(strPath, "/")
fldr = ""
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
For i = 0 To UBound(GetNewsFold)
If fldr = "" Then
fldr = FristStr & GetNewsFold(i)
Else
fldr = fldr & "\" & GetNewsFold(i)
End If
If FSO.FolderExists(Server.MapPath(fldr)) = False Then
Call FSO.CreateFolder(Server.MapPath(fldr))
End If
Next
Set FSO = Nothing
If Err.Number = 0 Then
Err.Clear
CreatePath = Replace(fldr, "\", "/") & "/"
Else
CreatePath = ""
End If
End Function
'' ============================================
'' function(公有)
'' 作用 :保存文件,并自動(dòng)創(chuàng)建多級(jí)文件夾
'' ============================================
Function SaveData(FromUrl, ToFiles, sCookie, sAgent, SaveType, SaveShow)
Dim strFile, NewPath
strFile = Replace(ToFiles, "\", "/")
strFile = Replace(strFile, Chr(0), "")
strFile = Replace(strFile, "http://", "/")
NewPath = Mid(strFile, 1, InStrRev(strFile, "/"))
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(Server.MapPath(strFile)) = False Then
If FSO.FolderExists(Server.MapPath(NewPath)) = False Then
Call CreatePath(NewPath)
End If
SaveData = SaveFiles(FromUrl, strFile, sCookie, sAgent ,SaveShow)
Else
'' 覆蓋文件
If SaveType = 1 Then
SaveData = SaveFiles(FromUrl, strFile, sCookie, sAgent ,SaveShow)
Else
SaveData = True
End If
End If
Set FSO = Nothing
End Function
%>


下面是一個(gè)使用的例子:
<!-- #include file = "Cls_AspHttp.asp" -->
<!-- #include file = "Function.asp" -->
<%
Dim DoGet
Dim sCookie
Dim sUserAgent


Set DoGet = New FlyCms_AspHttp

Rw "下載91f的文件<br>"
Down91f

Rw "<br>下載haoting的文件<br>"
DownHaoting

Set DoGet = Nothing



Sub Down91f()
''91f 欺騙身份

sCookie = ""
sUserAgent = "NSPlayer/9.0.0.2991 WMFSDK/9.0 " ''這句模擬Media Player身份
FromUrl = "http://202.101.235.99/mu/MP/@2AC6BFD79E8BA1E58860618CDD2CEEB14//f/71/2.Wma"
ToFiles

該文章在 2013/11/28 11:39:44 編輯過(guò)
關(guān)鍵字查詢(xún)
相關(guān)文章
正在查詢(xún)...
點(diǎn)晴ERP是一款針對(duì)中小制造業(yè)的專(zhuān)業(yè)生產(chǎn)管理軟件系統(tǒng),系統(tǒng)成熟度和易用性得到了國(guó)內(nèi)大量中小企業(yè)的青睞。
點(diǎn)晴PMS碼頭管理系統(tǒng)主要針對(duì)港口碼頭集裝箱與散貨日常運(yùn)作、調(diào)度、堆場(chǎng)、車(chē)隊(duì)、財(cái)務(wù)費(fèi)用、相關(guān)報(bào)表等業(yè)務(wù)管理,結(jié)合碼頭的業(yè)務(wù)特點(diǎn),圍繞調(diào)度、堆場(chǎng)作業(yè)而開(kāi)發(fā)的。集技術(shù)的先進(jìn)性、管理的有效性于一體,是物流碼頭及其他港口類(lèi)企業(yè)的高效ERP管理信息系統(tǒng)。
點(diǎn)晴WMS倉(cāng)儲(chǔ)管理系統(tǒng)提供了貨物產(chǎn)品管理,銷(xiāo)售管理,采購(gòu)管理,倉(cāng)儲(chǔ)管理,倉(cāng)庫(kù)管理,保質(zhì)期管理,貨位管理,庫(kù)位管理,生產(chǎn)管理,WMS管理系統(tǒng),標(biāo)簽打印,條形碼,二維碼管理,批號(hào)管理軟件。
點(diǎn)晴免費(fèi)OA是一款軟件和通用服務(wù)都免費(fèi),不限功能、不限時(shí)間、不限用戶(hù)的免費(fèi)OA協(xié)同辦公管理系統(tǒng)。
Copyright 2010-2025 ClickSun All Rights Reserved