1个回答
展开全部
<%
Function getHTTPPage(urls)
dim objXML
set objXML=server.createobject("MSXML2.XMLHTTP")'定义
objXML.open "GET",urls,false'打开
objXML.send()'发送
If objXML.readystate<>4 then '判断文档是否已经解析完,以做客户端接受返回消息
exit function
End If
getHTTPPage=BytesToBstr(objXML.responseBody)'返回信息,同时用函数定义编码
getHTTPPage=replace(getHTTPPage,"<","<")
'getHTTPPage=bytes2BSTR(objXML.responseBody)'或者返回信息时用函数转换汉字
set objXML=nothing'关闭
if err.number<>0 then err.Clear
End Function
Function BytesToBstr(body)
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 = "GB2312"
'转换原来默认的UTF-8编码转换成GB2312编码,否则直接用XMLHTTP调用有中文字符的网页得到的将是乱码
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
Dim Urls,Html
Urls="http开头网址"
Html = getHTTPPage(Urls)
response.write(Html)
%>
Function getHTTPPage(urls)
dim objXML
set objXML=server.createobject("MSXML2.XMLHTTP")'定义
objXML.open "GET",urls,false'打开
objXML.send()'发送
If objXML.readystate<>4 then '判断文档是否已经解析完,以做客户端接受返回消息
exit function
End If
getHTTPPage=BytesToBstr(objXML.responseBody)'返回信息,同时用函数定义编码
getHTTPPage=replace(getHTTPPage,"<","<")
'getHTTPPage=bytes2BSTR(objXML.responseBody)'或者返回信息时用函数转换汉字
set objXML=nothing'关闭
if err.number<>0 then err.Clear
End Function
Function BytesToBstr(body)
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 = "GB2312"
'转换原来默认的UTF-8编码转换成GB2312编码,否则直接用XMLHTTP调用有中文字符的网页得到的将是乱码
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
Dim Urls,Html
Urls="http开头网址"
Html = getHTTPPage(Urls)
response.write(Html)
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询