用ADODB.Stream转换

时间:2021-05-18

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

<HTML>
<html>
<head>
<METAhttp-equiv="Content-Type"content="text/html;charset=Big5">
<title>test</title>
<SCRIPTLANGUAGE="JavaScript">
<!--
window.onerror=function(err){
returnfalse;
};

//-->
</SCRIPT>
<scriptlanguage="vbscript">
<!--

'获取地址
dimsUrl

sUrl="http:///chi/Login/Login.asp"
Functionstreamtochar(StrStream)
setstream=CreateObject("ADODB.Stream")
stream.type=1
stream.Mode=3
stream.Open
stream.WriteStrstream
stream.Position=0
stream.Type=2
stream.Charset="BIG5"
streamtochar=stream.ReadText
stream.Close
setstream=nothing
EndFunction

'Functionbytes2BSTR(vIn)
'strReturn=""
'Fori=1ToLenB(vIn)
'ThisCharCode=AscB(MidB(vIn,i,1))
'IfThisCharCode<&H80Then
'strReturn=strReturn&Chr(ThisCharCode)
'Else
'NextCharCode=AscB(MidB(vIn,i+1,1))
'strReturn=strReturn&Chr(CLng(ThisCharCode)*&H100+CInt(NextCharCode))
i=i+1
'EndIf
'Next
'bytes2BSTR=strReturn
'EndFunction

'函数,得到内容
functiongetContentByUrl(url)

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

oXmlHttp.open"GET",url,false

oXmlHttp.send

getContentByUrl=streamtochar(oXmlHttp.responseBody)

setoXmlHttp=nothing
endfunction


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


getRealContent=sContent
endfunction


'-->
</script>
</head>
<bodyleftmargin="0"topmargin="0"marginwidth="0"marginheight="0">
<SCRIPTLANGUAGE=vbscript>
<!--
str=getRealContent(sUrl)
'document.write"<xmp>"&str&"</xmp>"
'document.writestr
document.write"<METAhttp-equiv=""Content-Type""content=""text/html;charset=Big5"">"&str

'-->
</SCRIPT>
</BODY>
</HTML>

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章