After a long try I’ve been able to create a script in vba which can successfully handle webpages with lazy-load. It can reach the bottom of a slow loading webpage if the hardcoded number of the loop is set accurately. I tried with few such pages and found it working flawlessly. The one I’m pasting below is created using
finance.yahoo site. It can parse the title of different news after going down to a certain level of that page according to the loop I’ve defined. Now, what I wanna expect to have is do the same thing without using hardcoded delay what I’ve already used in my script. Thanks in advance for any guidance to the improvement.
Here is what I’ve written:
Sub Web_Data() Dim IE As New InternetExplorer, html As HTMLDocument Dim storage As Object, posts As Object With IE .Visible = True .navigate "https://finance.yahoo.com/" Do While .readyState <> READYSTATE_COMPLETE: Loop Set html = .document End With Application.Wait Now() + TimeValue("00:00:005") For scroll_down = 1 To 10 Set storage = html.getElementsByClassName("StretchedBox") html.parentWindow.scrollBy 0, 99999 Application.Wait Now() + TimeValue("00:00:005") Next scroll_down For Each posts In storage Row = Row + 1: Cells(Row, 1) = posts.ParentNode.innerText Next posts IE.Quit End Sub
Reference to add to the library:
1. Microsoft Internet Controls 2. Microsoft HTML Object Library
✓ Extra quality
ExtraProxies brings the best proxy quality for you with our private and reliable proxies
✓ Extra anonymity
Top level of anonymity and 100% safe proxies – this is what you get with every proxy package
✓ Extra speed
1,ooo mb/s proxy servers speed – we are way better than others – just enjoy our proxies!
USA proxy location
We offer premium quality USA private proxies – the most essential proxies you can ever want from USA
Our proxies have TOP level of anonymity + Elite quality, so you are always safe and secure with your proxies
Use your proxies as much as you want – we have no limits for data transfer and bandwidth, unlimited usage!
Superb fast proxy servers with 1,000 mb/s speed – sit back and enjoy your lightning fast private proxies!
99,9% servers uptime
Alive and working proxies all the time – we are taking care of our servers so you can use them without any problems
No usage restrictions
You have freedom to use your proxies with every software, browser or website you want without restrictions
Perfect for SEO
We are 100% friendly with all SEO tasks as well as internet marketing – feel the power with our proxies
Buy more proxies and get better price – we offer various proxy packages with great deals and discounts
We are working 24/7 to bring the best proxy experience for you – we are glad to help and assist you!