Applescript / Javascript Help
Imported from the Apple Support Forums via the Wayback Machine 🔗
I have a script which, among other things, navigates to the first result in an Amazon search result page, and then extracts some information from the page. Up until today this has worked great, now it appears that Amazon has changed the coding of their page and my script is broken. I have been playing around with it for an hour now and cannot get it to work. Some help would be greatly appreciated!
Here is the element inspection using an example item:
Here is the section of my code as it sits currently:
tell application "Safari"
activate
open location "http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=" & upc
delay 2
do JavaScript "document.getElementById('search_result_0"').getElementsByTagName('a')[0].click()" in document 1
I see where the page references data-cel-widget="search_result_0", but I cannot figure out how to access it to get my script to click that first item. The script does also try the second item in the list if the first one is not the correct item, so I do need to be able to reference each item individually.
Any ideas? Thank you in advance!
8 replies
Sign in or join Beachball Help to reply.
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0