0

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.

What I want to fetch (34)
enter image description here

Powershell Code

$downloadURL     = 'https://example.html'
$downloadRequest = Invoke-WebRequest -Uri $downloadURL

Result
Data not in the output code from Powershell

1
  • i would help but I cant pull up the site in its entirety, could be my proxy. Have you tried using the Inspect feature in windows to see which tag that number falls under? Commented Nov 13, 2017 at 19:36

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot for that info... I am getting this error.. + $ie.document.body.getElementsByClassName('il-customers-affected-value menu-info- ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : MethodNotFound
Try to check which method is MethodNotFound by executing $ie | Get-Member, $ie.document | Get-Member, and $ie.document.body | Get-Member.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.