title: Powershell - Can't figure out how to get web content from IE object
body: <p>I am pretty new to <strong>Powershell</strong> and just using it for personal stuff. I have been experimenting with pulling specific info from websites to include in emails to family.  By reading the forums I got pretty good using the <code>Invoke-WebRequest</code> cmdlet, but soon hit upon its limitation of not having access to content constructed dynamically at the time the page is loaded.</p>
  
  <p>Thanks to these forums, I then discovered the IE object and how to pull the data.  I had luck with one website, but another I tried does not work the same.  Hoping for a little help figuring it out.</p>
  
  <p>Here is a snippet of the inspected code for the page, with my target of interest highlighted.</p>
  
  <p><img src="https://i.stack.imgur.com/jpHIg.jpg" alt="Web Page Snippet"></p>
  
  <p>Below is the code where I am trying to extract that text string.  I have tried many iterations and approaches with no success.  What is odd, though, the <code>$ie.Document</code> object supposedly has a "body" object, but when I tried to access it, I get a null object error.  I notice the Document object itself has a <code>getElementsByTagName</code> method, so I tried that.  It does not have a <code>getElementsByClassName</code> method.</p>
  
  <p>Note that the URL I am loading is "https" so I am wondering if this is causing issues.  Suggestions appreciated!  If I can just get a surrounding chunk of the HTML, I am fine doing some string manipulation to get what I want.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>#  Create IE object and load URL
  
  $WeatherURL = "https://weather.com/weather/today/l/77630"
  $ie = New-Object -comobject "InternetExplorer.Application"
  $ie.visible = $true
  $ie.navigate($WeatherURL)
  
   # Wait for the page to load 
  
  while ($ie.Busy -eq $true -Or $ie.ReadyState -ne 4) {Start-Sleep 2}
  
  $Doc = $ie.Document
  
  $Weather0 = $Doc.getElementsByTagName('span') `
   | ?{$_.getAttribute('class') -eq "today-wx-descrip"} | Select-Object -First 1</code></pre>
  </div>
  </div>
  </p>