Silly script for the day
So, you’d like to submit a URL to Open Laboratory 2008, you want to know if it’s already in Bora’s list and your machine runs Ruby? I thought so!
Save the following code as “bora.rb”, make it executable and run:
./bora.rb http://your.url.goes.here
#!/usr/bin/ruby
require 'rubygems'
require 'hpricot'
require 'open-uri'
def check_url(url)
d = Hpricot(open("http://scienceblogs.com/clock/2008/11/the_open_laboratory_2008_only.php"))
d.search('a[@href]').each {|a|
if url == a['href']
return "Already submitted: #{a.inner_text}"
end
}
return "No exact match found"
end
puts check_url(ARGV[0])
It will only match identical URLs and is missing all kinds of checks and tests.


