[C]通过XMLHTTP获取CGI/PHP等程序的返回值

来源:互联网 发布:linux tail相反 编辑:程序博客网 时间:2024/04/28 06:16

function getHTTPPage(url)
        dim Http 
        set Http=server.createobject("MSXML2.XMLHTTP") 
        Http.open "POST",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

Private 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

Dim Str_Url,Result
Result = getHTTPPage(Str_Url)

原创粉丝点击