vb.net批量查询已删除域名

vb.net批量查询已删除域名,第1张

概述这里使用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 domainCount += 1 '查询到域名加1 End If End If Next Me.TextBox1.Text = pageCount & "/" & totalPageCount '显示查询进度 Me.TextBox2.Text = domainCount & "/" & totalDomainCount '显示查询进度 Return result_Domain_name '返回该页域名查询结果 End Function Sub get_next_page() '获取下一页子过程,比较通用版本 Dim hasFirst_Page As Boolean = True If Webbrowser1.ReadyState = WebbrowserReadyState.Complete Then Dim doc As HTMLdocument = Webbrowser1.document Dim HTMLEC As HTMLElementCollection = doc.getElementsByTagname_r("a") Dim hyperlink As HTMLElement = nothing Dim tempurl As String = String.Empty Dim tempText As String = String.Empty Dim nexturl As String = String.Empty
For Each hyperlink In HTMLEC '判断是否有第一页 '判断是否有下一页 tempurl = hyperlink.GetAttribute("href") tempText = hyperlink.InnerText If tempurl.Contains("page=") AndAlso tempText <> String.Empty AndAlso tempText.Contains("下一页") Then System.IO.file.AppendAllText(outfilename,get_Domain_Detail()) '查询结果存盘 hasNext_Page = True pageCount = pageCount + 1 Exit For Else hasFirst_Page = False End If Next
If hasNext_Page = True And hyperlink.InnerText = "下一页" Then hyperlink.InvokeMember("click") Else System.IO.file.AppendAllText(outfilename,get_Domain_Detail()) '查询结果存盘 End If
End If End Sub Sub get_pages() '获取总页数及总域名数,新版本
If Webbrowser1.ReadyState = WebbrowserReadyState.Complete Then If pageCount = 1 Then '页码为1则开始获取总页数 Dim doc As String = Webbrowser1.document.Body.INNERHTML '网页body源代码 Dim yh = Chr(34) Dim exp As String = String.Empty exp = "找到 <b>(?<DnCount>\d+)</b> 条记录,共 <b>(?<DnPages>\d+)</b> 页" Dim MyExpression = New System.Text.RegularExpressions.Regex(exp,System.Text.RegularExpressions.RegexOptions.IgnoreCase) Dim Myinfo As String = String.Empty '读取文件内容 Dim MyMatches = MyExpression.Matches(doc) '正则匹配
For Each MyMatch In MyMatches Dim matchGroups As GroupCollection = MyMatch.groups totalDomainCount = matchGroups.Item("DnCount").ToString totalPageCount = matchGroups.Item("DnPages").ToString Next System.IO.file.AppendAllText(outfilename,get_Domain_Detail()) '查询结果存盘 End If If pageCount < totalPageCount Then '否者打开下一页 pageCount += 1 Me.Webbrowser1.Navigate(chinaz_DelUrl & "&page=" & pageCount) System.IO.file.AppendAllText(outfilename,get_Domain_Detail()) '查询结果存盘 ElseIf pageCount = totalPageCount Then MsgBox("域名查询已完成") End If End If
End Sub
Private Sub Webbrowser1_documentCompleted(ByVal sender As System.Object,ByVal e As System.windows.Forms.WebbrowserdocumentComple tedEventArgs) Handles Webbrowser1.documentCompleted If actionType = 0 Then WebLogin(Webbrowser1,"esonbest","eson_165") ElseIf Webbrowser1.ReadyState = WebbrowserReadyState.Complete And actionType = 1 Then ' get_next_page() '查看是否有下一页,并统计明细 get_pages() End If End Sub
Private Sub button3_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Me.Close() '退出程序
End Sub
Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load Dim path As String = System.IO.Directory.GetCurrentDirectory & "\readme.HTML" Webbrowser1.Navigate(path) '各项查询参数的取值可以查看del.chinaz.com 的网页源代码和查询是的url来确定查询URL End Sub
Private Sub button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles button1.Click '登录chinaZ actionType = 0 Webbrowser1.Navigate("http://my.chinaz.com/login.HTML") End Sub End Class 总结

以上是内存溢出为你收集整理的vb.net批量查询已删除域名全部内容,希望文章能够帮你解决vb.net批量查询已删除域名所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1267175.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-08
下一篇 2022-06-08

发表评论

登录后才能评论

评论列表(0条)

保存