Help with getting dates from website with user input using Applescript

l0g0p7
New Contributor

Hi,

I was wondering if someone could help me with debugging my script.

My aim is to ask the user for a number and once entered then extract the date associated with that number eg. user input of 997 (Sg:AU 997), with the Sg:AU being the default answer, results in the date 1986-01-24

Current problem is that no matter what number I enter it only results in 1986-02-12. Also, it would be nice to have the cursor sitting at the end of the default answer instead of highlighting it.

My script (apple) so far...

set theResponse to display dialog "Catalogue number?" default answer "Sg:AU " buttons {"Cancel", "Continue"} default button "Continue"
set sgno to (text returned of theResponse)

tell application "Google Chrome"
    repeat with x from 0 to ((execute active tab of first window javascript "document.getElementsByClassName('i_d').length") - 1)
        set theDate to execute active tab of first window javascript "document.getElementsByClassName('i_d')[" & x & "].outerHTML"
        if theDate contains sgno then exit repeat
    end repeat
    set theDate to execute active tab of first window javascript "document.getElementsByTagName('dd')[" & x & "].innerHTML"
end tell

return theDate

And the website I'm using https://colnect.com/en/stamps/list/country/8147-Australia/year/1986

Thank you
l0g0p7

0 REPLIES 0