是否可以使用 vba 与 selenium 结合创建后期绑定(bind)方法?如果是的话那会怎么样呢?我搜索了很多但找不到任何匹配。对此的任何帮助将不胜感激。
如下所示:
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 component can't create object
最佳答案
我相信您正在寻找的是:
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
但如果可能的话,最好使用早期绑定(bind)。
关于vba - 使用 selenium 在 vba 中创建后期绑定(bind)方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49176598/