title: How to parse the HTML of a website with PowerShell
body: <p>I am trying to retrieve some information about a website, I want to look for a specific tag/class and then return the contained text value (innerHTML). This is what I have so far</p>
  
  <pre><code>$request = Invoke-WebRequest -Uri $url -UseBasicParsing
  $HTML = New-Object -Com "HTMLFile"
  $src = $request.RawContent
  $HTML.write($src)
  
  
  foreach ($obj in $HTML.all) { 
      $obj.getElementsByClassName('some-class-name') 
  }
  </code></pre>
  
  <p>I think there is a problem with converting the HTML into the HTML object, since I see a lot of undefined properties and empty results when I'm trying to "Select-Object" them.</p>
  
  <p>So after spending two days, how am I supposed to parse HTML with Powershell?</p>
  
  <ul>
  <li>I can't use <code>IHTMLDocument2</code> methods, since I don't have Office installed (<a href="https://stackoverflow.com/questions/46307976/unable-to-use-ihtmldocument2">Unable to use IHTMLDocument2</a>)</li>
  <li>I can't use the <code>Invoke-Webrequest</code> without <code>-UseBasicParsing</code> since the Powershell hangs and spawns additional windows while accessing the ParsedHTML property (<a href="https://stackoverflow.com/questions/50344462/parsedhtml-doesnt-respond-anymore">parsedhtml doesnt respond anymore</a> and <a href="https://stackoverflow.com/questions/15211573/using-invoke-webrequest-in-powershell-3-0-spawns-a-windows-security-warning">Using Invoke-Webrequest in PowerShell 3.0 spawns a Windows Security Warning</a>)</li>
  </ul>
  
  <p>So since parsing HTML with regex is such a big no-no, how do I do it otherwise? Nothing seems to work.</p>