Created
December 3, 2010 05:43
-
-
Save xoebus/726625 to your computer and use it in GitHub Desktop.
Gets playtime of a profile's games.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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