' ============================================
' 利用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
' 利用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
解决方案 »
- 求一份.net论坛源码!!!
- 无法将类型为“System.DBNull”的对象强制转换为类型“System.String”。
- 求一套完整的生成静态的asp.net网站(带源码),我感激不尽!
- ASP中的System.NullReferenceException:
- 菜鸟提问:ASP.NET 运行时错误: 该应用程序的配置文件必须包含“trust”节 什么意思?
- 请求高手帮助?
- 谁有Wrox公司出版的由清华大学引进的<<C# Web 应用程序入门经典>>的范例代码?
- “/”应用程序中的服务器错误
- 做好的网站上传到空间有Server Error in '/' Application 高手帮帮忙啊
- 如何使一个textbox web控件获得焦点时,使它的text属性文本为空?
- ASP.NET关于cache的使用
- 怎样使本页面的变量能在页面中用户控件里使用?
______________________________________________________
免费ASP.NET空间申请http://www.kingtoo.com/pdtshw/hstshw/index.asp,
支持ASP.NET1.1, 2.0
100M asp.net 空间只要50元(www.kingtoo.com)
http://huobazi.cnblogs.com/archive/2004/02/23/1521.html