Hello to everybody here. I hope you are doing well.
Here is my task. I need to open a web page, find there a specific element, let's say some text. Then I need to copy the text to my worksheet. My code works, yet it takes way too long to open some web pages due to detected automation. I don't want my macros to load the whole page for 30 seconds, one second will be enough to get the information I need. Is there a way to stop loading the page just with VBA and Selenium? If not, is the a way to do it with VBA and some other software?
Thank you in advance
Here is my task. I need to open a web page, find there a specific element, let's say some text. Then I need to copy the text to my worksheet. My code works, yet it takes way too long to open some web pages due to detected automation. I don't want my macros to load the whole page for 30 seconds, one second will be enough to get the information I need. Is there a way to stop loading the page just with VBA and Selenium? If not, is the a way to do it with VBA and some other software?
Thank you in advance
VBA Code:
Option Explicit
Private cd As Selenium.ChromeDriver
Public Sub Copy()
Dim i As Integer 'just a counter
Set cd = New Selenium.ChromeDriver
cd.Start
cd.Get ("....") 'loading a webpage, takes way too long
Dim Headlines As Selenium.WebElements
Dim Headline As Selenium.WebElement
Set Headlines = cd.FindElementsByClass("lpl-1")
i = 1
For Each Headline In Headlines
ThisWorkbook.Sheets("Sheet1").Cells(1, i).Value = Headline.Text
i = i + 1
Next Headline
End Sub