Created
May 26, 2012 09:09
-
-
Save dwayne/2793034 to your computer and use it in GitHub Desktop.
Get Play Whe results using Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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