Forum

VBA code to Click o...
 
Notifications
Clear all

VBA code to Click on the load more button

6 Posts
2 Users
0 Reactions
146 Views
(@raj)
Posts: 21
Eminent Member
Topic starter
 

Hi, I am editing a vba program and want macro code to click on button in a web page which is below the page. The html for the button is:

Load More WO Notes

If the button does not exists then my macro should run as is. if load button exists then it should be clicked once it loads the  data run the rest of the macro file.

My macro code is below. i want the macro inserted after the Next in the below code.

With Ws Html.body.innerHTML = ie.document.querySelectorAll(".list").Item(1).outerHTML
Set Dates = Html.querySelectorAll(".wo-notes-col-1")
Set Matters = Html.querySelectorAll(".wo-notes")
For i = 0 To Dates.Length - 1
Lr = ThisWorkbook.Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row + 1
.Cells(Lr, 1) = Dates.Item(i).innerText
.Cells(Lr, 2) = Matters.Item(i).innerText
Next
End With
Thanks please ask any question if needed.
 
Posted : 10/04/2020 2:59 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Rajsha,

It sounds like you are trying to click a button on a web page to go to the next page and get the data on that next page.

I'll need to know the page/url you are trying to get data from.  I can't write any code to interact with the website unless I can examine that page and identify a way to interact with this button.

Also, please attach your workbook with code in your reply.

Regards

Phil

 
Posted : 10/04/2020 10:55 pm
(@raj)
Posts: 21
Eminent Member
Topic starter
 

Hi Philip, 

Thanks for your reply on this query.  What you assumed in the email is exactly what i need. And my sincere apologies that i cant provide URL details due to restrictions. I understand that with out seeing the task or the way of working of the HTML code no one can guess the VBA code. Is there any other thing that i can provide in this regard. 

Regards

Rajsha

 
Posted : 11/04/2020 12:46 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Rajsha,

I wrote a post on interacting with webpages which may be of help to you

Web scraping filling in forms

 

But if the website uses pagination that is controlled in the URL something like:

website.com/?page=x

then you can just load the next page by changing x and resubmitting the url.  I cover this approach here

Web scraping multiple pages

Regards

Phil

 
Posted : 11/04/2020 1:03 am
(@raj)
Posts: 21
Eminent Member
Topic starter
 

Hi Philip, Thanks for letting me know with the above links. I got some idea with that links. Thanks for your hard work in this.

 
Posted : 11/04/2020 1:37 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

You're welcome.

 
Posted : 11/04/2020 4:23 am
Share: