title: Get all elements in a div with VBA
body: <p>I am trying to scrape Project Gutenberg.</p>
  <p>I am able to use the .getElementsByClassName(&quot;chapter&quot;) to get the divs that hold the chapters. However, I am unable to get all the elements in that div as a collection that I would then be able to iterate over.</p>
  <pre><code>Sub getZ()
  Dim H As Object, C As New DataObject, stryn&amp;, cptr%, html As New HTMLDocument, p As HTMLHtmlElement, para As Object, i&amp;
  Set H = CreateObject(&quot;WinHTTP.WinHTTPRequest.5.1&quot;)
  
  Application.ScreenUpdating = False
  
  With H
      .SetAutoLogonPolicy 0
      .SetTimeouts 0, 0, 0, 0
      .Open &quot;GET&quot;, &quot;https://www.gutenberg.org/files/8164/8164-h/8164-h.htm&quot;, False
      .Send
      .WaitForResponse
  End With
  
  html.body.innerHTML = H.ResponseText
  Set para = html.getElementsByClassName(&quot;chapter&quot;).getElementsByTagName(&quot;*&quot;)
  
  i = 1
  
  For Each p In para
      Worksheets(&quot;Output&quot;).Range(&quot;A&quot; &amp; i &amp; &quot;&quot;) = p.innerText
      i = i + 1
  Next
  
  Application.ScreenUpdating = True
  End Sub
  </code></pre>
  <p>I am getting an error with getElementsByTagName(&quot;*&quot;) as the object doesn't support that method.</p>