[Code]<%
function getHTTPPage(url)
dim httpxml
Set httpxml= server.CreateObject("msxml2.XMLHTTP")
httpxml.open "get",url,False
httpxml.send()
if httpxml.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Httpxml.responseBody,"GB2312")
set httpxml=nothing
if err.number<>0 then err.Clear
end function ‘ 2、转换乱玛,直接用xmlhttp调用有中文字符的网页得到的将是乱玛,可以通过adodb.stream组件进行转换
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
%>[/Code]
上面的代码在代码第二次生成的时候不会更新,下面的代码加上时间就好了!
[Code]<%
function getHTTPPage(byval url)
if instr(url,"?")>0 then
url=url&"&d="&now()
else
url=url&"?d="&now()
end if
dim httpxml
Set httpxml= server.CreateObject("msxml2.XMLHTTP")
httpxml.open "get",url,False
httpxml.send()
if httpxml.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Httpxml.responseBody,"GB2312")
set httpxml=nothing
if err.number<>0 then err.Clear
end function ‘ 2、转换乱玛,直接用xmlhttp调用有中文字符的网页得到的将是乱玛,可以通过adodb.stream组件进行转换
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
%>
[/Code]
评论前必须登录!
注册