Monday, July 22, 2013

A simple one-liner for repeatedly querying a remote XPath from the command line!

I often want to monitor a single element on a page, but I don't feel like firing up python to make it happen.

Using a tool called xidel, this command will write the results of an xpath query to a file every 300 seconds:

yes "xidel YOUR_URL_HERE -e \"YOUR_XPATH_HERE\" 2> /dev/null; sleep 300"|sh > output.txt

Here's a working example:
yes "xidel http://www.indiegogo.com/projects/ubuntu-edge -e \"/html//p[@id='big-goal']\" 2> /dev/null; sleep 300"|sh > output.txt