我已经用vba
和selenium
编写了一个脚本。如果我注释掉我可能为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