Skip to content

Instantly share code, notes, and snippets.

@dwayne
Created May 26, 2012 09:09
Show Gist options
  • Save dwayne/2793034 to your computer and use it in GitHub Desktop.
Save dwayne/2793034 to your computer and use it in GitHub Desktop.
Get Play Whe results using Ruby
require 'net/http'
month = 'Apr' # Mmm
year = '11' # yy
host = 'nlcb.co.tt'
path = 'search/pwq/countdateCash.php'
uri = URI("http://#{host}/#{path}")
# http://ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/Net/HTTP.html#method-c-post_form
res = Net::HTTP.post_form(uri, 'month' => "#{month}", 'year' => "#{year}")
if res.code == "200"
# Here's the current form of the data on the page as of 25/05/2012:
#
# <date>: Draw # <number> : <period>'s draw was <mark>
#
# where
#
# <date> : dd-Mmm-yy
# <number>: a positive integer
# <period>: Morning | Midday | Evening
# <mark> : 1..36
results = res.body.to_s.scan(/(\d{2})-#{month}-#{year}: Draw # (\d+) : (Morning|Midday|Evening)'s draw was (\d+)/)
if results.empty?
puts "No results"
else
puts results
end
else
puts "Error: #{res.message}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment