asp 问题~

来源:百度知道 编辑:UC知道 时间:2024/05/09 14:10:57
我打算用ASP得到一个网页的源码。
怎样操作?
view-soucrse
这个可是不行的啊~HELP

rem 输入url目标网页地址,返回值getHTTPPage是目标网页的html代码
Function getHTTPPage(url)
On Error Resume Next
dim Http
Set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.send()
If Http.readystate<>4 Then
Exit Function
end If
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
Set http=nothing
If err.number<>0 Then err.Clear
end Function

rem 转换乱玛,直接用xmlhttp调用有中文字符的网页得到的将是乱玛,可以通过adodb.stream组件进行转换
Function BytesToBstr(body,Cset)
On Error Resume Next
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

rem 去除H