Team, I am trying to click on load more button, I'm able to click and run the macro with no issues for only one click. that is for one time. I need help for the below points
I'm trying to automate the code to repeat the click button until the page loads all the data for web scraping.
Also, i need a code to check the load more button in the web page exists or not before web scraping the data to excel. If "Load more" button not found proceed with the next code. (FYI Load more exists at the bottom of my web page).
Thanks and please reply me if my question is not clear.
below is the Html code before clicking load more button
<button type="button" class="btn primary btn-primary modal-button-print add-notes" data-bind="click: getNotes, visible: isLoadMoreButtonEnable() && !$root.providerShouldAcceptDecline()">
<i class="fa fa-refresh" aria-hidden="true"></i>Load More
</button>
below is the Html code after clicking load more button multiple times until it loads full data
<button class="btn primary btn-primary modal-button-print add-notes" style="display: none;" type="button" data-bind="click: getWoNotes, visible: isLoadMoreNotesButtonEnable() && !$root.providerShouldAcceptDecline()">
<i class="fa fa-refresh" aria-hidden="true"></i>Load More Work Order Notes
</button>
The difference i see from the above html code is style="display: none;" got added after i click button multiple times till it loads full data in web page.
I have a sample web site that looks similar to my webpage. I took this link here to just show how the page loads in my website.
Sub abc()
Set IE = New InternetExplorer
Link = my url
.
.
.
.
For L = 2 To Lr1
IE.navigate Link
Set Html = New MSHTML.HTMLDocument
Set Ws = Scraping
Do
DoEvents: Loop Until IE.readyState = READYSTATE_COMPLETE
Application.Wait (Now + TimeValue("00:00:05"))
IE.document.querySelector("button[type=button]").Click
Do
DoEvents: Loop Until IE.readyState = READYSTATE_COMPLETE
Application.Wait (Now + TimeValue("00:00:05"))
IE.document.querySelector("button[type=button]").Click
Do
DoEvents: Loop Until IE.readyState = READYSTATE_COMPLETE
Application.Wait (Now + TimeValue("00:00:05"))
IE.document.querySelector("button[type=button]").Click
Do
DoEvents: Loop Until IE.readyState = READYSTATE_COMPLETE
Application.Wait (Now + TimeValue("00:00:05"))
Html.body.innerHTML = IE.document.querySelectorAll(".list").Item(1).outerHTML
Set Tariku = Html.querySelectorAll(".columns")
Set data = Html.querySelectorAll(".datalist")
With Ws
' Do all the stuff
End With
IE.document.querySelector("#Logout").Click
IE.Quit
Exit Sub
Next L
End Sub
querySelector(), which addresses exactly the first button found.