【问题标题】:Creating latebinding approach in vba using selenium使用 selenium 在 vba 中创建后期绑定方法
【发布时间】:2018-03-08 15:21:40
【问题描述】:

是否可以结合使用 vba 和 selenium 创建后期绑定方法?如果是,那会怎样?我搜索了很多,但找不到任何匹配项。对此的任何帮助将不胜感激。

如下所示:

Sub Test_Selenium()
    Dim post As Object

    With CreateObject("ChromeDriver") ''it's a faulty approach as I'm not familiar with it
        .get "https://stackoverflow.com/questions/tagged/web-scraping"
        For Each post In .FindElementsByCss(".question-hyperlink")
            r = r + 1: Cells(r, 1) = post.Text
        Next post
        .Quit
    End With
End Sub

它会产生常见错误

activeX 组件无法创建对象

【问题讨论】:

    标签: vba excel selenium web-scraping selenium-chromedriver


    【解决方案1】:

    我相信您正在寻找的是:

    Sub Test_Selenium()
        Dim post As Object
    
        With CreateObject("Selenium.ChromeDriver")
            .get "https://stackoverflow.com/questions/tagged/web-scraping"
            For Each post In .FindElementsByCss(".question-hyperlink")
                r = r + 1: Cells(r, 1) = post.Text
            Next post
            .Quit
        End With
    End Sub
    

    但如果可能的话,最好还是使用早期绑定。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-09
      • 1970-01-01
      • 1970-01-01
      • 2023-03-29
      • 2018-04-13
      • 1970-01-01
      相关资源
      最近更新 更多