品教教育网
您的当前位置:首页用ADODB.Stream转换_javascript技巧

用ADODB.Stream转换_javascript技巧

来源:品教教育网


用ADODB.Stream转换,用streamtochar这个函数





test

window.onerror = function (err) {
return false;
};

//-->



'获取地址
dim sUrl

sUrl="http://www.aastocks.com/chi/Login/Login.asp"
Function streamtochar(StrStream)
set stream=CreateObject("ADODB.Stream")
stream.type=1
stream.Mode=3
stream.Open
stream.Write Strstream
stream.Position= 0
stream.Type= 2
stream.Charset="BIG5"
streamtochar= stream.ReadText
stream.Close
set stream=nothing
End Function

'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

'函数,得到内容
function getContentByUrl(url)

'建立对象
set oXmlHttp = CreateObject("MSXML2.XMLHTTP")

oXmlHttp.open "GET",url,false

oXmlHttp.send

getContentByUrl = streamtochar(oXmlHttp.responseBody)

set oXmlHttp=nothing
end function


'函数,获得网站内容
function getRealContent(url)
sContent = getContentByUrl(url)


getRealContent=sContent
end function


'-->




str=getRealContent(sUrl)
'document.write "

"&str &""
'document.write str
document.write ""&str

'-->


显示全文