nasdaqhe's blog

被生活强jian着
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

利用xmlHTTP获取网页源码[asp]

Posted on 2006-10-27 17:11  nasdaqhe  阅读(449)  评论(0编辑  收藏  举报
<%
'利用xmlHTTP获取网页源码
strScriptCurrentDirectory = "http://"&request.serverVariables("SERVER_NAME")&":"&request.serverVariables("SERVER_PORT")_
 
&request.serverVariables("SCRIPT_NAME")
strScriptCurrentDirectory 
= left(strScriptCurrentDirectory,len(strScriptCurrentDirectory)-len(split(strScriptCurrentDirectory,"/")(ubound(split(strScriptCurrentDirectory,"/")))))

Function funGetHTTPPage(priStrPath,priStrMothed)
    priT 
= funGetBody(priStrPath,priStrMothed)
    funGetHTTPPage 
= funBytesToBstr(priT, "GB2312")
End Function

Function funGetBody(priStrUrl,priStrMothed)
    
'On Error Resume Next
    Set Retrieval = CreateObject("Microsoft.XMLHTTP")
    
With Retrieval
        .Open priStrMothed, priStrUrl, 
False""""
        .Send
        funGetBody 
= .ResponseBody
    
End With
    
Set Retrieval = Nothing
End Function

Function funBytesToBstr(priBody, priCSet)
    
Set objStream = Server.CreateObject("adodb.stream")
    objStream.Type 
= 1
    objStream.Mode 
= 3
    objStream.Open
    objStream.Write priBody
    objStream.Position 
= 0
    objStream.Type 
= 2
    objStream.CharSet 
= priCSet
    funBytesToBstr 
= objStream.ReadText
    objStream.Close
    
Set objStream = Nothing
End Function
%
>