Skip to content

Instantly share code, notes, and snippets.

@jasonm
Forked from thoughtbot/stocknames-random-api.rb
Created August 21, 2009 20:40
Show Gist options
  • Save jasonm/172414 to your computer and use it in GitHub Desktop.
Save jasonm/172414 to your computer and use it in GitHub Desktop.
# via http://robots.thoughtbot.com/post/168368158/lets-get-ready-to-rummmmmmmble
require 'rubygems'
require 'hpricot'
require 'open-uri'
def get_stock_name
doc = Hpricot(open('http://stocknames.info'))
names = doc / '.list ul li'
names[rand(names.size)].innerText
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment