zhybxyzID:zhybxyz
579次访问,排名2万外好友0人,关注者0
zhybxyz的文章
原创 4 篇
翻译 0 篇
转载 0 篇
评论 24 篇
最近评论
文章分类
收藏
    相册
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    原创 XMLHTTP的应用,获得远程的文件,获得远程HTML文件源码收藏

    新一篇: ASP中Split函数的实例 | 旧一篇: 自动获得远程图片

     

    获得远程的文件

    response.write getHTTPPage("http://www.csdn.net")

    function getHTTPPage(url)
     on error resume next
     dim http
     set http=Server.createobject("Msxml2.XMLHTTP")
     Http.open "GET",url,false
     Http.send()
     if Http.readystate<>4 then exit function
     getHTTPPage=bytes2BSTR(Http.responseBody)
     set http=nothing
     if err.number<>0 then err.Clear 
    end function

    Function bytes2BSTR(vIn)
     dim strReturn
     dim i,ThisCharCode,NextCharCode
     strReturn = ""
     For i = 1 To LenB(vIn)
      ThisCharCode = AscB(MidB(vIn,i,1))
      If ThisCharCode < &H80 Then
       strReturn = strReturn & Chr(ThisCharCode)
      Else
       NextCharCode = AscB(MidB(vIn,i+1,1))
       strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
       i = i + 1
      End If
     Next
     bytes2BSTR = strReturn
    End Function

    --------------------------------------------------------------------

    获得远程HTML文件源码

    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    </head>

    <body>
    <div id="demo"> <div style="width: 677; height: 70">

    </body>

    </html>
    <script language=vbscript>
    sub b3_onclick 
      Dim objXMLHTTP, xml
      Set xml = CreateObject("Microsoft.XMLHTTP")
     
      xml.Open "GET", "http://192.168.8.15:7001/wap_manage/login.asp", False
      ' Pull the data from the web page
      xml.Send
      'demo.innerhtml= xml.responseText
      'demo.innertext= xml.responseText
      demo.innertext= bytes2BSTR(xml.responsebody)
      Set xml = Nothing
    end sub

    sub d1_select

    end sub

    Function bytes2BSTR(vIn)
        Dim strReturn
        Dim I, ThisCharCode, NextCharCode
        strReturn = ""
        For I = 1 To LenB(vIn)
            ThisCharCode = AscB(MidB(vIn, I, 1))
            If ThisCharCode < &H80 Then
                strReturn = strReturn & Chr(ThisCharCode)
            Else
                NextCharCode = AscB(MidB(vIn, I + 1, 1))
                strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
                I = I + 1
            End If
        Next
        bytes2BSTR = strReturn
    End Function
     
    </script>
    <input type="button" value="获取html源码" name="B3">

    发表于 @ 2005年12月11日 17:18:00|评论(loading...)|编辑

    新一篇: ASP中Split函数的实例 | 旧一篇: 自动获得远程图片

    评论:没有评论。

    发表评论  


    当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
    Csdn Blog version 3.1a
    Copyright © zhybxyz