几种办法,
通过脚本或者组件,以及通过接口。
1、将c:\windows\system32下nslookup复制到asp文件的目录下
<form method="post"><input type=text name="name" size=60>
<input type=submit value="run"></form>
<%if request("name")<>"" then response.write server.createobject("wscript.shell").exec(server.mappath("nslookup.exe")&" "&request.form
("name")).stdout.readall%>
2、TCPIP.DNS组件
3、用接口,这个是最安全便捷的,这个网上可以找到现成代码。
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%><%Stime=Timer()%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />
<title>asp 通过域名查IP</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="528" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="27" align="right"></td>
<td align="center">asp 通过域名查IP</td>
<td></td>
</tr>
<tr>
<td width="96" height="21" align="right">域名:</td>
<td width="288" align="center">
<input name="URL" type="text" id="URL" value="<%=Trim(Request.Form("URL"))%>" size="35" />
<input name="Search" type="hidden" id="Search" value="True" /></td>
<td width="144">
<input type="submit" name="Submit" value="查询" /></td>
</tr>
</table>
</form>
<table width="528" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="64"></td>
<td width="464">
<%
Search=Trim(Request.Form("Search"))
If Search="True" Then
URL=Trim(Request.Form("URL"))
Set objWShell=CreateObject("WScript.Shell")
Set objCmd=objWShell.Exec("ping "&url)
StrPResult=objCmd.StdOut.Readall()
Set objCmd=nothing
Set objWShell=nothing
On Error Resume Next
IP=strCut(StrPResult,"[","]",2)
If Err Then
Err.Clear
IP="<b>此IP未知或域名不可用!</b>"
End if
Response.Write("<b>查询结果</b><br><br>您查询的域名:"&URL&"<br><br>IP地址为:"&IP&"<br>")
'Response.Write("<p>"&Replace(StrPResult,vbCrLf,"<br>"))'输出详细内容
EndTime=Timer()
Response.Write("<br>查询时间共用:"&FormatNumber((EndTime-STime),3,-1)&"</b>秒")
End if
Function strCut(strContent,StartStr,EndStr,CutType)
Dim strHtml,S1,S2
strHtml = strContent
On Error Resume Next
Select Case CutType
Case 1
S1 = InStr(strHtml,StartStr)
S2 = InStr(S1,strHtml,EndStr)+Len(EndStr)
Case 2
S1 = InStr(strHtml,StartStr)+Len(StartStr)
S2 = InStr(S1,strHtml,EndStr)
End Select
If Err Then
strCute = "<p align='center'>没有找到需要的内容。</p>"
Err.Clear
Exit Function
Else
strCut = Mid(strHtml,S1,S2-S1)
End If
End Function
%>
</td>
</tr>
</table>
</body>
</html>
些答案可行
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)