CODE:[Copy to clipboard]Function GetBody(weburl) '-----------------翟振恺(小琦) '创建对象 Dim ObjXMLHTTP Set ObjXMLHTTP=Server.CreateObject("MSXML2.serverXMLHTTP") '请求文件,以异步形式 ObjXMLHTTP.Open "GET",weburl,False ObjXMLHTTP.send While ObjXMLHTTP.readyState <> 4 ObjXMLHTTP.waitForResponse 1000 Wend '得到结果 GetBody=ObjXMLHTTP.responseBody '释放对象 Set ObjXMLHTTP=Nothing '-----------------翟振恺(小琦) End Function 调用方法: GetBody(文件的URLf地址) 2、或XMLHTTP组件获取数据
CODE:[Copy to clipboard]Function GetBody(weburl) '-----------------翟振恺(小琦) '创建对象 Set Retrieval = CreateObject("Microsoft.XMLHTTP") With Retrieval .Open "Get", weburl, False, "", "" .Send GetBody = .ResponseBody End With '释放对象 Set Retrieval = Nothing '-----------------翟振恺(小琦) End Function 调用方法: GetBody(文件的URLf地址) 这样获取的数据内容还需要进行编码转换才可以使用
CODE:[Copy to clipboard]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