1:====================================================
response.Write(GetBody("http://www.chinaxg.com.cn"))
Function GetBody(weburl)
'创建对象
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
Retrieval.Open "Get", weburl, False, "", ""
Retrieval.Send()
GetBody = bytes2BSTR(Retrieval.ResponseBody)
End With
'释放对象
Set Retrieval = 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
===============================================================
2================================================================
response.Write(GetBody("http://www.chinaxg.com.cn"))
Function GetBody(weburl)
'创建对象
Dim ObjXMLHTTP
Set ObjXMLHTTP=Server.CreateObject("MSXML2.serverXMLHTTP")
'请求文件,以异步形式
ObjXMLHTTP.Open "GET",weburl,False
ObjXMLHTTP.send
While ObjXMLHTTP.readyState <> 4
ObjXMLHTTP.waitForResponse 1000
Wend
'得到结果
GetBody=bytes2BSTR(ObjXMLHTTP.responseBody)
'释放对象
Set ObjXMLHTTP=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
=================================================================
3==================================================================
Dim objAdoStream
set objAdoStream = Server.createObject("ADODB.Stream")
objAdoStream.Type = 1
objAdoStream.Open()
objAdoStream.write("asdfas")
objAdoStream.SaveToFile server.MapPath("stream.htm"),2
objAdoStream.Close()
response.Write("chenggong")
response.End()
=====================================================================
4====================================================================
response.Write(BytesToBstr("asdfasdf","GB2312"))
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
=====================================================================
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
Trackback: http://tb.donews.net/TrackBack.aspx?PostId=804680