I would like to write a script which would find some specific datas in a web page and return it in a pop up box
The code below works perfectly for a given string of characters. The issue is that each time a new product its checked, the string will change.
This is how it would look when checking the page source:
<randomcharacters<!---->evenmorerandomcharacters<!----> 9999 <!----></div>
There will always be 2 <!---->
before the number I want to grab and <!----></div>
after the number I want to grab. The number of random characters before the number I want to grab is not consistent either
tell application "Safari"
set unitsgrab to do JavaScript "document.getElementsByClassName('theclassIwant')[0].innerHTML;" in current tab of window 1
end tell
set units to ""
set theSource to unitsgrab
property leftEdge : "randomcharacters<!---->evenmorerandomcharacters<!---->"
property rightEdge : "<!----></div>"
try
set saveTID to text item delimiters
set text item delimiters to leftEdge
set classValue to text item 2 of theSource
set text item delimiters to rightEdge
set units to text item 1 of classValue
set text item delimiters to saveTID
units
end try
display dialog "Units:" & (units)
What I actually want to do is tell the script to delete everything up to the second <!---->
in order to only have 9999 display in my example above