I am trying to get all links for each object, in order to make a log of which items are new and which are old
I dont understand how to grab links from a shopping website...
Tis is the code that works.
$URI = 'http://superwidgets.wordpress.com/category/sql/'
$HTML = Invoke-WebRequest -Uri $URI
($HTML.ParsedHtml.getElementsByTagName('h2') | Where{ $_.className -eq 'entry-title' } )
This code does not
$url = 'https://www.norrona.com/nb-NO/o/herre/?displaysize=L%7CM&s=7&h=69000'
$x = Invoke-WebRequest -Uri $URL
($x.ParsedHtml.getElementsByTagName('div') | Where{ $_.className -eq 'productcard' } )
WHY?
This works but there is no div element with a productcard classname. Html and Javascript are just a bunch of text that are not rendered by any browser when retrieved from PowerShell. This means all the javascript is not executed.
There is a <script> element that is:
<script src="/api/translation/JavascriptInject?groups=Global&groups=ProductList&groups=Product&groups=Payment&groups=PrePurchase"></script>
<main id="vueProductList" role="main">
</main>
that probably should be invoked to render the elements you look for.
But this is another call to another web ressource that probably return javascript objects. This doesn't tell if the objects would be styled with a productcard CSS class when rendered by javascript code.
This is probably not the right way to get the product list. You should directly access the API (if available) to get the list of products. You can then use PowerShell to convert json to powershell objects with ConvertFrom-Json cmdlet.