VBA/Excel - Multiple website scrape returns duplicates

I have been scraping data from multiple websites and pulling into excel the inner text of a specific tag from each of those. The code goes as follow:

For Each x In Range("C2:C30")
If x <> Blank Then

    With Web
        .navigate Cells(x.Row, 3).Value
    End With
    Do While Web.Busy
    DoEvents
    Loop

    Set Doc = Web.document
    Set AllClass = Doc.getElementsByClassName("name")

    On Error Resume Next
    vName = AllClass(0).innerText

    Cells(x.Row, 1).Value = vName

    Next x

Now this works, however, it randomly returns duplicate results. It seems to not properly load the entire page before pulling in the information although I do have the 'DoEvents' inserted at the beginning of the loop. For example, I should be getting the following information from five websites:

  1. Bob
  2. John
  3. Jane
  4. Joe
  5. Hank

Instead I get something like this (which randomly varies):

  1. Bob
  2. John
  3. John
  4. Joe
  5. Hank

And running the macro again would randomly yield:

  1. Bob
  2. John
  3. Jane
  4. Jane
  5. Jane

I would suspect that this has to do with IE scraping the data from the previous page because it couldn't finish loading the website. No idea how to fix this..

Thanks!


ANSWERS:


Do not only check Busy but also ReadyState (it should be 4 when page loading has finished)



 MORE:


 ? Use different IP in browser control C#
 ? How to mute Webbrowser in Windows Forms Application?
 ? How to get any web site alert message UWP WebView
 ? WebBrowser control resize
 ? How to login to website using webbrowser control
 ? How to use System.Windows.Forms.WebBrowser in a web app?
 ? wpf: change font size for WebBrowser control
 ? Change port number used by .NET WebBrowser Control
 ? Converting an HtmlElement into an Image?
 ? handle keyboard events / shortcuts in hosted web browser control