G
Gary Thomas
I am interested in downloading, from the New Zealand TAB (Totalisator Agency
Board) website, the names of the race meetings on a particular date. This is
normally reached from the TAB main page (www.tab.co.nz) through their
results page which has a form with date dropdown (and uses HTTPS). Picking
(for example) 20 April 2007 leads to a web page with the URL
ebet.tab.co.nz/ebet/ResultsArchive?day=20&month=04&year=2007
If I copy this URL and paste it into another instance of my web browser
(Mozilla), it produces the correct list of meetings. On the other hand, if I
try and access it through Ruby, I get a zero length response body (and an
obscure error if I switch on the debug as in the example below). My code is:
uri =
URI.parse('https://ebet.tab.co.nz/ebet/ResultsArchive?day=20&month=04&year=2
007')
request = Net::HTTP.new(uri.host, uri.port)
request.set_debug_output $stderr
request.use_ssl = true
request.verify_mode = OpenSSL::SSL::VERIFY_NONE
response = request.get2(uri.path)
puts response.body.size
If I pass the parameters as a second parameter, hashed, to the get2 call I
get exactly the same results (that is, an error).
Can someone point out my mistake in this code which works pretty well in
other situations?
Gary Thomas
Board) website, the names of the race meetings on a particular date. This is
normally reached from the TAB main page (www.tab.co.nz) through their
results page which has a form with date dropdown (and uses HTTPS). Picking
(for example) 20 April 2007 leads to a web page with the URL
ebet.tab.co.nz/ebet/ResultsArchive?day=20&month=04&year=2007
If I copy this URL and paste it into another instance of my web browser
(Mozilla), it produces the correct list of meetings. On the other hand, if I
try and access it through Ruby, I get a zero length response body (and an
obscure error if I switch on the debug as in the example below). My code is:
uri =
URI.parse('https://ebet.tab.co.nz/ebet/ResultsArchive?day=20&month=04&year=2
007')
request = Net::HTTP.new(uri.host, uri.port)
request.set_debug_output $stderr
request.use_ssl = true
request.verify_mode = OpenSSL::SSL::VERIFY_NONE
response = request.get2(uri.path)
puts response.body.size
If I pass the parameters as a second parameter, hashed, to the get2 call I
get exactly the same results (that is, an error).
Can someone point out my mistake in this code which works pretty well in
other situations?
Gary Thomas