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")
    %>
  • 相关阅读:
    PHP之常用设计模式
    MySQL之慢查询日志和通用查询
    mysql之找回误删数据
    PHPer未来路在何方...
    如何成为更优秀的程序员
    常见的 CSRF、XSS、sql注入、DDOS流量攻击
    API接口TOKEN设计
    成为更好的程序员的八中途径
    奉秉格言
    PHP优化与提升
  • 原文地址:https://www.cnblogs.com/chengulv/p/2862058.html
Copyright © 2011-2022 走看看