不能在Selenium vba 脚本中使用代理



我已经用vbaselenium编写了一个脚本。如果我注释掉我可能为proxy错误定义的行,脚本就可以完成它的工作。

如何使用proxy运行刮刀?我搜索了很多,但找不到可以帮助我解决这个问题的匹配项。

这是我的尝试:

Sub UseProxy()
Dim driver As New ChromeDriver, post As Object
With driver
.setProxy "38.131.10.78:53281"
.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

如果我执行宏,它会抛出一个错误object doesn't support this method ------

如下,来自@Ulixestotaca:的方法

Option Explicit
Private Sub Use_Proxy()
Dim d As WebDriver, post As Object, R As Long
Set d = New ChromeDriver
With d
.Start
.Proxy.SetHttpProxy "38.131.10.78:53281" 
.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

相关内容

  • 没有找到相关文章

最新更新