概述这里使用chinaZ的接口查询已删除域名,中间省略了些函数,大家可以自己写一下。 后期还需要增加备案查询,以及百度domain查询。 Imports System.Text.RegularExpressions Public Class Form1 Public pageCount As Integer = 1 '以查询到域名结果页数 Public domainCount As I 这里使用chinaZ的接口查询已删除域名,中间省略了些函数,大家可以自己写一下。 后期还需要增加备案查询,以及百度domain查询。 imports System.Text.RegularExpressions Public Class Form1 Public pageCount As Integer = 1 '以查询到域名结果页数 Public domainCount As Integer = 0 '查询到域名个数 Public hasNext_Page As Boolean = False '是否有下一页 Public outfilename As String = "域名查询结果.txt" Public totalPageCount As Integer = 0 '查询结果的总也数,用正则表达式匹配第一页源码得到 Public totalDomainCount As Integer = 0 '查询结果的总域名数,用正则表达式匹配第一页源码得到 Public chinaz_DelUrl As String = "http://del.chinaz.com/?kw=&p=0&bl=4&el=8&ds[]=1&pl=&hs=1&sort=1&suffix[]=com&dt=1&date=1&pagesize=200&st=1" '各项查询参数的取值可以查看del.chinaz.com 的网页源代码和查询是的url来确定查询URL Private Sub button4_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles button4.Click pageCount = 1 actionType = 1 '1---进行查询 hasNext_Page = False If System.IO.file.Exists(outfilename) Then System.IO.file.Delete(outfilename) End If Me.Webbrowser1.Navigate(chinaz_DelUrl) End Sub
Function get_match_text(ByVal doctext As String) '从HTML文档中提取 tbody 部门源码 Dim yh = Chr(34) Dim exp As String = String.Empty exp = "<tbody>(.|\n)*</tbody>" Dim MyExpression = New System.Text.RegularExpressions.Regex(exp,System.Text.RegularExpressions.RegexOptions.IgnoreCase) Dim Myinfo As String = String.Empty '读取文件内容 Dim MyMatches = MyExpression.Matches(doctext) '正则匹配 For Each MyMatch In MyMatches Myinfo += vbCrLf + String.Format(MyMatch.Value) Next Return Myinfo End Function
Function get_Domain_Detail() '获取域名查询结果函数 Dim htmdoc As HTMLdocument = Webbrowser1.document Dim tableStr As String = get_match_text(htmdoc.Body.INNERHTML) Dim web = New Webbrowser web.Navigate("about:blank ") Dim tablehtmldoc = web.document.OpenNew(True) tablehtmldoc.Write(tableStr) Dim HTMLES As System.windows.Forms.HTMLElementCollection = tablehtmldoc.getElementsByTagname_r("a") '获取域名 Dim td_Count As Integer = HTMLES.Count Dim i As Integer = 0 Dim result_Domain_name As String = String.Empty '查询结果 Dim single_Domain_name As String = String.Empty '单个域名结果 Dim tagID As String = String.Empty For i = 0 To HTMLES.Count.ToString - 1 single_Domain_name = HTMLES.Item(i).InnerText On Error Resume Next tagID = HTMLES.Item(i).ID If single_Domain_name <> String.Empty AndAlso tagID <> String.Empty Then If tagID.Contains("domain_") And single_Domain_name.Contains(".") Then 'A标签ID包含domain_ 的即为查询结果 If result_Domain_name = String.Empty And pageCount = 1 Then result_Domain_name = single_Domain_name '第一个数据 Else result_Domain_name = result_Domain_name & vbCrLf & single_Domain_name '每个数据用换行分割 End If