Skip to content

Instantly share code, notes, and snippets.

@xoebus
Created December 3, 2010 05:43
Show Gist options
  • Save xoebus/726625 to your computer and use it in GitHub Desktop.
Save xoebus/726625 to your computer and use it in GitHub Desktop.
Gets playtime of a profile's games.
require 'nibbler'
require 'open-uri'
class SteamProfile < Nibbler
elements 'div.gameListRowItem' => :games do
element 'h4' => :title
element 'h5' => :playtime, :with => lambda { |time|
time.inner_text.strip.split(" ").first.to_f
}
end
end
def profile name
SteamProfile.parse open("http://steamcommunity.com/id/#{name}/games?tab=all")
end
profile("amazoph").games.each { |game| p "#{game.title} - #{game.playtime}" }
profile("staticshock").games.each { |game| p "#{game.title} - #{game.playtime}" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment