| The following Ruby program parses the leaders html page and produces a simple report of the first 10 entries. I wasn't sure if Arc had the ability to scrape a web page yet, so I assumed input from a file. Just curious how Arc fares with simple parsing and formatting. PATTERN = /(\d\d?)\..*?.+?<u>(.+?)<\/u>.+?(\d+)</m
sum = count = 0
File.new("arcleaders.html").read.scan(PATTERN) do |index, user, score|
puts "%2.2s. %-15s = %4d" % [index, user, score.to_i]
sum += score.to_i
count += 1
break if count >= 10
end
puts '='*26
puts 'Total = %4d' % sum
puts 'Average = %4d' % (sum / count)
Output is as follows (note alignment): brian@airstream:~/sync/code/ruby$ ruby arcleaders.rb
1. almkglor = 926
2. sacado = 600
3. nex3 = 594
4. kennytilton = 454
5. kens = 411
6. lojic = 369
7. eds = 300
8. cchooper = 275
9. absz = 248
10. drcode = 209
==========================
Total = 4386
Average = 438
|