0

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.

How can I run my scraper using proxy? I searched a lot but could not find a match that could help me solve this.

This is my try:

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 ------.

SIM
  • 21,997
  • 5
  • 37
  • 109

1 Answers1

2

As follows, from method by @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
QHarr
  • 83,427
  • 12
  • 54
  • 101