5 ms·
I was curious: danielha : 3.52 danw  
by brett 20y ago
I was curious:
danielha : 3.52
danw : 3.24
brett : 6.10
python_kiss : 4.24
mattculbreth : 5.34
sharpshoot : 7.06
jwecker : 3.88
staunch : 4.57
amichail : 2.30
Harj : 5.74
Alex3917 : 11.77
joshwa : 4.62
far33d : 4.84
nostrademons : 7.50
jamiequint : 7.26
Sam_Odio : 6.06
Elfan : 5.00
domp : 3.44
zaidf : 5.93
dfranke : 6.40
Readmore : 5.00
paul : 15.67
blader : 7.56
phil : 7.44
mattjaynes : 5.72
herdrick : 6.24
palish : 29.60
veritas : 4.08
bootload : 2.18
BioGeek : 10.06
- brett 20y agothe code: require 'rubygems' require 'active_support' require 'net/http' Net::HTTP.start('news.ycombinator.com', 80) do |http| body = http.get('/leaders').body users = body.scan(/user\?id=([^"]+)/) users.each do |user| body = http.get("/submitted?id=#{user}").body points = body.scan(/(\d+) points? by/).map(&:first).map(&:to_f) puts "%-15s : %6.2f" % [user, points.sum / points.size] end end
- brett 20y agoI'm really wishing I could figure out how to get <br>s into comments instead of just <p>s.
- michelson01 20y agothis might have been easier using hpricot, rubyful soup, scrapi, scrupyt, or something like that.
- brett 20y agoYeah. I started with a require 'hpricot' line and then took it out when I realized pg does not put any classes or other identifying attributes in his html. CSS selectors and XPaths with just html elements seem hard to read. "td td u a" does not look so hot to me. Regexs are pretty easy.
- ralph 20y agoIt looks to me like the submitted page lists at most 50 posts. Here's my script which shows the problem. I've hex-encoded it to get it through the posting system unbuggered. python -c 'print "77676574202d714f202d20687474 703a2f2f6e6577732e79636f6d6269 6e61746f722e636f6d2f6c656164657273 207c0a74722027223e2720275c6e5c6e27207 c0a736564202d6e2027732f 5e757365723f69643d2f2f7027207c0a7 8617267732 02d726920776765 74202d714f202d20276874747 03a2f2f6e6577732e79636f6d62696e6 1746f722e636f6d2f 7375626d6 9747465643f69643d7b7d27 207c0a747220273e2720275c6e27207c0a736 564202d6e2027732f5e5c285b302d395d5b302d 395d2a5c2920706f696e74732 a206279202e2a3d 5c282e2a5c 292e242f5c32205c312f7 027207c0a61776b20277b635b243 15d2b2b3b20735b24315d 202b3d20243 27d0a20202020454e4420 7b666f7220286e20 696e206329 207072696e74 662022252d32 307320253564202 535642025372e32665c6e22 2c206e2c20635b6e 5d2c20735 b6e5d2c20735b6e5d2 02f20635b6e5d7d27207c0 a736f7274202 b336e720a".replace(" ", "").decode("hex"),' Cheers, Ralph.