谢谢分享!民政局每月都会公布完整最新的行政区域资料,尝试分析下网页,比较简单,可以轻松抓取出来,如下:(供需要的人参考)
dim add as string = “http://www.mca.gov.cn/article/sj/xzqh/2020/2020/202101041104.html”
Dim web As New System.Windows.Forms.WebBrowser()
web.Navigate(add)
Do Until web.ReadyState = 4
Application.DoEvents
Loop
'取数据
Dim tbl As System.Windows.Forms.HtmlElement
Dim ss As String
tbl = web.Document.GetElementsByTagName("table")(0)
Dim trs As object = tbl.GetElementsByTagName("tr")
For i1 As Integer = 3 To trs.count -1
Dim td1 As object = trs(i1).GetElementsByTagName("td")(1)
Dim sd1 As String = td1.innertext
Dim td2 As object = trs(i1).GetElementsByTagName("td")(2)
Dim sd2 As String = td2.innertext
sd1 = sd1.Replace(" ","")
sd2 = sd2.Replace(" ","")
ss = ss & "|" & sd1 & "-" & sd2
If sd2 = "澳门特别行政区" Then
Exit For
End If
Next
ss = ss.Trim("|")
FileSys.WriteAllText(ProjectPath & "data\行政区域.Txt",ss,false)
[此贴子已经被作者于2021/4/30 15:07:02编辑过]