'***函数名 : GetPageCode
'***函数说明: 获取URL源码
'***参数 :
' sURL: 指定URL网址
' sCharset: 编码
'***返回值 : URL源码
Function GetPageCode(sURL, sCharset)
Dim Http, sPageCode
Set Http = Server.CreateObject("Microsoft.XMLHTTP")
If Err Then
Set Http = Server.CreateObject("MSXML2.XMLHTTP")
Err.Clear()
End If
Http.Open "Get", sURL, False
Http.Send()
If Http.ReadyState=4 And Http.Status=200 Then
sPageCode = BytesToBstr(Http.ResponseBody, sCharset)
End If
Set Http = Nothing
GetPageCode = sPageCode
End Function
Function BytesToBstr(sBody, sCharset)
Dim objStream
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = 1
objStream.Mode = 3
objStream.Open()
objStream.Write(sBody)
objStream.Position = 0
objStream.Type = 2
objStream.Charset = sCharset
BytesToBstr = objStream.ReadText
objStream.Close()
Set objStream = Nothing
End Function