Skip to content

Instantly share code, notes, and snippets.

@grosser
Created September 10, 2011 12:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save grosser/1208263 to your computer and use it in GitHub Desktop.
Save grosser/1208263 to your computer and use it in GitHub Desktop.
Most recommended games on Steam

Get the most recommended games from steam (because steam does not tell...) this is an example and no invitation to DDos steam ;)

id = ARGV[0].to_i # starting id is first argument
MAX = 50 # max requests
MAX_FAILS = 20 # abort after 20 failures -- at end of catalog ?
SEARCH = /([\d+,]+) players recommend this game to their friends/
TITLE = %r{<title>(.*?)</title>} # title of the app
max = id + (MAX * 10)
fails = 0
results = []
def url(id)
"http://store.steampowered.com/app/#{id}"
end
def pretty(count,id,title)
"#{count} : #{title} : #{url(id)}"
end
loop do
page = `curl '#{url(id)}' 2> /dev/null`
if page =~ SEARCH
count = $1.sub(',','').to_i
title = (page.match(TITLE)[1] || '???').sub(' on Steam','')
result = [count, id, title]
puts "Found #{pretty(*result)}"
results << result
fails = 0
elsif page.strip.empty? # curl failed ... page does not exist
puts "Not Found #{id}"
fails += 1
if fails > MAX_FAILS
puts "Stopped at #{id}"
break
end
else
fails = 0
puts "No rating #{id}"
end
break if id > max
id += 10 # every 10th id is filled
end
puts results.sort.reverse.map{|data| pretty(*data) }
Result of first 50 games:
208952 : Team Fortress 2 : http://store.steampowered.com/app/440
59257 : Counter-Strike: Source : http://store.steampowered.com/app/240
31131 : Counter-Strike : http://store.steampowered.com/app/10
21213 : Portal : http://store.steampowered.com/app/400
15006 : Half-Life 2 : http://store.steampowered.com/app/220
11695 : Left 4 Dead : http://store.steampowered.com/app/500
7964 : Day of Defeat: Source : http://store.steampowered.com/app/300
6600 : Half-Life 2: Deathmatch : http://store.steampowered.com/app/320
4971 : Half-Life : http://store.steampowered.com/app/70
3410 : Counter-Strike: Condition Zero : http://store.steampowered.com/app/80
3329 : Half-Life 2: Episode Two : http://store.steampowered.com/app/420
2233 : Half-Life 2: Lost Coast : http://store.steampowered.com/app/340
1867 : Half-Life 2: Episode One : http://store.steampowered.com/app/380
1781 : Day of Defeat : http://store.steampowered.com/app/30
1442 : Team Fortress Classic : http://store.steampowered.com/app/20
1324 : Ricochet : http://store.steampowered.com/app/60
1129 : Half-Life: Opposing Force : http://store.steampowered.com/app/50
1001 : Half-Life: Source : http://store.steampowered.com/app/280
703 : Half-Life: Blue Shift : http://store.steampowered.com/app/130
578 : Deathmatch Classic : http://store.steampowered.com/app/40
407 : Half-Life Deathmatch: Source : http://store.steampowered.com/app/360
....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment