Skip to content

Instantly share code, notes, and snippets.

@craigw
Created December 18, 2009 10:45
Show Gist options
  • Save craigw/259429 to your computer and use it in GitHub Desktop.
Save craigw/259429 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
require 'rubygems'
require 'net/http'
require 'cgi'
require 'hpricot'
name = CGI.escape(ARGV[0])
postcode = CGI.escape(ARGV[1])
response = Net::HTTP.get(URI.parse("http://www.beerintheevening.com/pubs/results.shtml?n=#{name}&st=&tc=&pc=#{postcode}"))
doc = Hpricot(response)
pub = (doc / "td.pubtable b a")[0]
if pub
puts "http://www.beerintheevening.com#{pub['href']}"
else
puts "Unknown"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment