我试图从类似的表中提取结果:
我已应用以下代码,但似乎无法正常工作。关于应该使用哪些表元素的任何想法?:
Sub Macro1()
Dim IE As New InternetExplorer
Dim CompetitionLink As String
CompetitionLink = ThisWorkbook.Worksheets("Settings").Range("B2")
IE.Navigate CompetitionLink
IE.Visible = True
Rank = IE.Document.getElementsByTagName("grid sc")(0).Rows(1).Cells(2).innerText
Debug.Print Rank
End Sub
答案 0 :(得分:0)
尝试该代码
Sub Test()
Dim ie As New InternetExplorer
Dim competitionLink As String
Dim rank As String
competitionLink = ThisWorkbook.Worksheets("Settings").Range("B2")
With ie
.Visible = True
.navigate competitionLink
Do: DoEvents: Loop Until .readyState = 4
rank = .document.getElementsByClassName("grid sc")(0).Rows(1).Cells(2).innerText
Debug.Print rank
End With
End Sub

**您也可以获取所有表数据..看看这个链接 Scrape HTML Table