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

0

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.