【问题标题】:Results extraction from website从网站提取结果
【发布时间】:2018-02-21 03:06:14
【问题描述】:

我试图从类似的表中提取结果:

https://data.fei.org/Result/ResultList.aspx?p=D6E828828E450E2880525ABCEE800008C1D381967CBAF718D9DE41BEBA3B9F06

我已经应用了以下代码,但似乎不起作用。关于应该使用哪些表格元素的任何想法?:

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

【问题讨论】:

  • 您需要等待页面加载&“grid sc”不是TagName。
  • grid scnot html 标签名称;可能是一堂课。

标签: excel html-table html-tableextract vba


【解决方案1】:

试试那个代码

    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

【讨论】:

    猜你喜欢
    • 2012-11-20
    • 1970-01-01
    • 2018-12-10
    • 2016-10-13
    • 1970-01-01
    • 2015-03-21
    • 2021-06-19
    • 1970-01-01
    • 2023-04-06
    相关资源
    最近更新 更多