I am trying to learn how to build a web scraper to improve my productivity at work. I found a site that gives an example and step by step guide on how to build a rudimentary scraper but when I put the code into my script editor I get the error "the variable input is not defined." number -2753 from "input". the code looks like this:
to getInputByClass(theClass, num) -- defines a function with two inputs, theClass and num
tell application "Safari" --tells AS that we are going to use Safari
set input to do JavaScript "document.getElementsByClassName('" & theClass & "')[" & num & "].innerHTML;" in document 1
end tell
return input
end getInputByClass
getInputByClass("r", 0)
Any help on how to fix the code would be greatly appreciated.