Reputation: 1025
I am not sure what I am doing wrong. I am trying to fetch the data from URL below.
But I am not getting anything in return using the code below.
Powershell Code
$downloadURL = 'https://example.html'
$downloadRequest = Invoke-WebRequest -Uri $downloadURL
Result
Data not in the output code from Powershell
Upvotes: 0
Views: 210
Reputation: 703
The page is dynamically created with JavaScript. It is hard to get the data by using Invoke-WebRequest
cmdlet. Instead of that, try to use Internet Explorer COM object like this:
$url = 'https://example.com'
$ie = New-Object -ComObject InternetExplorer.Application
$ie.Visible = $false
$ie.Navigate2($url)
while($ie.ReadyState -ne 4) { Start-Sleep 1 }
$ie.document.body.getElementsByClassName('example-class-name')::outerHTML
$ie.document.body.getElementsByClassName('example-class-name')::textContent
For more information, see this article.
Upvotes: 1