' ============================================
' 利用XML技术来获取网页数据
' ============================================
Public Function GetHTTPPage(Url)
Dim HTTP
On Error Resume Next
Set HTTP = Server.CreateObject("Microsoft.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' 按照指定的正则表达式返回字符
' ============================================
Public Function RegExpSearch(Patrn, Str, sType, Spacer)
Dim RegEx, Match, Matches , RetStr, i
i = 0
Set RegEx = New RegExp
RegEx.Pattern = Patrn
RegEx.IgnoreCase = True
RegEx.Global = True
Set Matches = RegEx.Execute(Str)
For Each Match In Matches
i = i + 1
If sType = 0 Then
RetStr = RetStr & Match.Value
If i < Matches.Count Then RetStr = RetStr & Spacer
Else
RetStr = RetStr & Match.Value
If i < Matches.Count Then RetStr = RetStr & Spacer
If sType = i Then Exit For
End If
Next
RegExpSearch = RetStr
End Function' 利用XMLHTTP获取域名解析后的IP地址
Dim Dm_Arr, Dm_Num, Dm_Par

' 获取网页数据
Dm_Par = iXs.GetHTTPPage("http://www.hexillion.com/samples/AspLookup.asp?addr=" & Domain)%>
<%
' 判断是否存在错误信息
If InStr(LCase(Dm_Par), "<tt><strong>host not found</strong></tt>") > 0 Then Call iXs.Alert("这个域名不存在,解析失败,请检查您的输入!", 0, 0) ' 该域名不存在!
If InStr(LCase(Dm_Par), "<tt><strong>no data</strong></tt>") > 0 Then Call iXs.Alert("这个域名合法,但是解析失败,请检查您的输入!", 0, 0) ' 该域名不存在!
' 利用正则表达式获取包含IP串的字符串
Dm_Par = CStr(iXs.RegExpSearch("<tt><strong>((0|[1-9]\d?|[0-1]\d{2}|2[0-4]\d|25[0-5])\.(0|[1-9]\d?|[0-1]\d{2}|2[0-4]\d|25[0-5])\.(0|[1-9]\d?|[0-1]\d{2}|2[0-4]\d|25[0-5])\.(0|[1-9]\d?|[0-1]\d{2}|2[0-4]\d|25[0-5])(<br>)?)+</strong></tt>", Dm_Par, 1, ""))
Dm_Par = CStr(iXs.RegExpFilter("<.+?>", Dm_Par, 1, "|"))

Dm_Arr = Split(Dm_Par, "|")
Dm_Num = 0
Dm_Par = ""
For i = 0 To UBound(Dm_Arr)
If iXs.IsIp(Dm_Arr(i)) = True Then
Response.Write("<tr align=""left"" bordercolor=""#FFFFFF"" bgcolor=""#FFFFFF"" onMouseOver=""this.bgColor='#F0F0F0';"" onMouseOut=""this.bgColor='#FFFFFF';"">")
Response.Write("<td colspan=""2""><span class=""Font_1"">·</span><a href=""Look_Ip.asp?Action=1&IpStr=" & iXs.Format_Ip(Dm_Arr(i)) & """ target=""_blank""><strong class=""red"" title=""点击查询 " & iXs.Format_Ip(Dm_Arr(i)) & " 的单个定位"">" & iXs.Format_Ip(Dm_Arr(i)) & "</strong></a> → <strong class=""green"">" & Look_Ip(Dm_Arr(i)) & "</strong></td>")
Response.Write("</tr>")
Dm_Num = Dm_Num + 1
End If
%>
' 按照指定的正则表达式替换字符
' ============================================
Public Function RegExpFilter(Patrn, Str, sType, ReplaceWith)
Dim RegEx
Set RegEx = New RegExp
If sType = 1 Then
RegEx.Global = True
Else
RegEx.Global = False
End If
RegEx.Pattern = Patrn
RegEx.IgnoreCase = True
RegExpFilter = RegEx.Replace(Str, ReplaceWith)
End Function

解决方案 »

  1.   

    抢个沙发先.....
    ______________________________________________________
    免费ASP.NET空间申请http://www.kingtoo.com/pdtshw/hstshw/index.asp,
    支持ASP.NET1.1, 2.0
    100M asp.net 空间只要50元(www.kingtoo.com)
      

  2.   

    see:
    http://huobazi.cnblogs.com/archive/2004/02/23/1521.html
      

  3.   

    这是用XmlHttp,用脚本来做的用VBScript或者JavaScript都可以实现。楼主上面 GetHTTPPage RegExpSearch 两个方法都是用VBScript实现的,直接拿到ASP.NET应用中的aspx页面中可以直接使用。<% ... %> 需要用VB.NET或者C#重新实现。楼主ASP.NET中可以用Ajax.net, ProAjax 等实现,更简单。ASP.NET 2.0 用Atlas更简单。