Fitocracy is a great site for tracking exercise, one which manages to have both a very friendly culture and an impressively gung-ho attitude. But they've never gotten around to implementing any kind of official API. If you want to look up your Fitocracy score from inside a script, you need to jump through a surprising number of hoops.
What we need is a generic web scraping tool like mechanize, but with the abilitity to deal with a rich JavaScript UI. It turns out the easiest way to do this is to use a headless web browser.
First, let's create a Ruby Gemfile
. We'll use capybara-webkit
, which is
normally used for testing Ruby websites:
source"https://rubygems.org"gem"capybara"gem"capybara-webkit"# Optional, if you want to debug using save_and_open_page.#gem 'launchy'