Invoke-Webrequest innertext is hidden?

Melmix 121 Reputation points
2021-02-20T08:05:37.07+00:00

Hello. I'm trying to create a script which will tell me when a an item comes in stock again on a website. This method works on other sites, but not on this one, where the innertext is empty. Can someone please help me understand why it is empty and if there is a way for me to get the text I need?

What I'm doing:

$URL = 'https://www.bilka.dk/produkter/sony-playstation-5-standard/100532624/'

$response = Invoke-WebRequest -Uri $URL
$classname ='stock-status__headline font-weight-bold'
$notInStock = 'Ikke på lager online'
$InStock = ($response.ParsedHtml.body.getElementsByClassName($classname) | select -expand innertext)

I'm trying to get this text:

70244-picture.jpg

Any help would be greatly appreciated. Thank you :-)

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2021-02-22T09:07:29.757+00:00

    Hi,

    It seems the element you tried to get is created by /_nuxt/product.js. Invoke-WebRequest only returns the HTML elements and it doesn't execute javascript.

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.