无法在Selenium VBA脚本中使用代理 [英] Can't use proxy within selenium vba script
本文介绍了无法在Selenium VBA脚本中使用代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用 vba
和 selenium
结合在一起编写了一个脚本.如果我注释掉为 proxy
错误定义的那行,该脚本可以很好地完成工作.
I've written a script in vba
in combination with selenium
. The script does it's jobs just fine if I comment out the line I may have wrongly defined for proxy
.
如何使用 proxy
运行刮板?我进行了很多搜索,但找不到匹配项可以帮助我解决此问题.
How can I run my scraper using proxy
? I searched a lot but could not find a match that could help me solve this.
这是我的尝试:
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
如果我执行宏,它将引发错误对象不支持此方法------
.
If I execute the macro, It throws an error object doesn't support this method ------
.
推荐答案
如下所示,来自 @Ulixestoitaca :
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
这篇关于无法在Selenium VBA脚本中使用代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文