zoukankan      html  css  js  c++  java
  • ASP函数 获取域名解析后的IP 获取远程网页的HTML代码

    <%
    '获取  域名解析后的IP
    Function strCut(strContent)
        strLineArr=split(strContent,vbCrlf)
        for each strLine in strLineArr
            if instr(strLine,":")>0 then
                getArr=split(strLine,":")
                if LCase(getArr(0))="addresses" then
                    strCut=split(Trim(getArr(1)),",")(0)
                    exit function
                end if
            end if
        next
        strCut="err"
    End Function
     
    Function getIP(Domain)
        Set objWShell=Server.CreateObject("WScript.Shell")
        Set objCmd=objWShell.Exec(server.mappath("nslookup.exe")&" "&Domain)
        StrPResult=objCmd.StdOut.Readall()
        Set objCmd=nothing
        Set objWShell=nothing
        getIP=strCut(StrPResult)
    End Function
     
    response.write getIP("www.baidu.com")
    %>
    <%
    '获取远程网页的HTML代码
    Function getHTTPPage(url) 
        On Error Resume Next
        dim http 
        set http=Server.createobject("Microsoft.XMLHTTP") 
        Http.open "GET",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 
            Response.Write "<p align='center'><font color='red'><b>服务器获取文件内容出错</b></font></p>" 
            Err.Clear
        End If  
    End Function
    
    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
    
    response.write getHTTPPage("http://www.baidu.com")
    %>
  • 相关阅读:
    C# 0xC0000005 捕获
    “Task”未包含“Run”的定义
    Win10 清理自带APP
    SQLServer 2014 内存优化表
    PHP 常用函数
    Android开发之旅:环境搭建及HelloWorld
    C# PropertyGrid控件应用心得
    SQL Server 连接池 (ADO.NET) MSDN
    查看数据库连接池函数
    WCF客户端调用服务器端错误:"服务器已拒绝客户端凭据"。
  • 原文地址:https://www.cnblogs.com/chengulv/p/2862058.html
Copyright © 2011-2022 走看看