Webscript
Russ Cox
September 8, 2010
research.swtch.com/webscript
Posted on Wednesday, September 8, 2010.
Russ Cox
September 8, 2010
research.swtch.com/webscript
Posted on Wednesday, September 8, 2010.
Back in 2005, before JavaScript was required for everything on the web, I created a toy language called webscript, to let you script automatic web interactions. I wanted to use webscript to replace some clunky wget-based shell scripts we were using to do things like track packages and reboot computers. Two real webscript programs illustrate the language.
This used to work for tracking UPS packages:
#!./webscript
load "http://www.ups.com/WebTracking/track?loc=en_US"
find textbox "InquiryNumber1"
input "1z30557w0340175623"
find next checkbox
input "yes"
find prev form
submit
if(find "Delivery Information"){
find outer table
print
}else if(find "One or more"){
print
}else{
print "Unexpected results."
find page
print
}
And this used to work to connect to a APC power strip and reboot the computer named yoshimi:
#!./webscript load "http://apc-reset/outlets.htm" print print "\n=============\n" find "yoshimi" find outer row find next select input "Immediate Reboot" submit print
I say that the scripts used to work because I haven't run them in a few years.
One of the goals of webscript was to let the programmer describe the
interactions with the web page instead of working with the raw form
parameters, so that scripts would even as the hidden plumbing behind
the web page changed. Even so the UPS script mentions InquiryNumber1.
Every few years I go looking for a replacement for webscript, but I never find anything. As more web sites require JavaScript to do anything useful, the job of implementing something like webscript gets harder. I think you'd essentially have to link against a browser to make it work.
Do you know of a tool like webscript that works with today's web pages? Do you know an easy way to make one? (I know about AppleScript and Chickenfoot, but I'd prefer something that can run and produce output as a command line program, without even displaying a web browser on my screen, so that it can be used in shell scripts and cron jobs.)