what I am looking for is that URL to a small image.
Can i do this programmatically?
I suppose I could use a regular expression to get the image URL https://m.media-amazon.com/images/I/41iuSZgmF2L.__AC_SX300_SY300_QL70_ML2_.jpg if I had downloaded the HTML file.
Are there any other techniques I could use, even outside javascript, such as AppleScript ?
It will return the URL from the page that correspond to the landingImageUrl data. I'm sure it can be improved by someone with more JS knowledge than myself, but it works.
Sounds like there is not, in fact, a corresponding match in the page open in your browser.
To get a query selector or xpath match that does find your target, in the page which you have opened, you will need to experiment with searches in the browser's Inspect view.
(I don't think you've told us which browser you are using ?)
If I run the Text content found by XPath macro, with the link which you supplied opened in Safari, or in Google Chrome, the macro displays:
I enabled the Macro
I am using KBM Version 10.2 and Chrome [121.0.6167.85 ] with various plugins [macOS 14.2.1]
I shall try using your example with Safari
The version above uses the modern JS syntax (and easier – also more secure – access to Keyboard Maestro variable values) of Keyboard Maestro version 11.