From: 7stud -- Date: 2009-02-17T22:15:06+09:00 Subject: Re: Parsing CSV file into a database Bosko Ivanisevic wrote: > Probably cut-paste caused error. Here is my slightly rewritten script > and output: > I get the same error: require 'net/http' require 'date' def get_historical_data(symbol, startDateString, endDateString) startDate = Date.parse(startDateString) endDate = Date.parse(endDateString) query = "/table.csv?s=#{symbol}&g=d" query.concat("&a=#{startDate.month-1}&b=#{startDate.mday}&c=# {startDate.year}") query.concat("&d=#{endDate.month-1}&e=#{endDate.mday}&f=# {endDate.year.to_s}") Net::HTTP.start("itable.finance.yahoo.com", 80) { |http| res = http.get(query) res.body } end puts get_historical_data("MSFT", "12/28/2008", "1/7/2009") --output:-- $ ruby r1test.rb /usr/lib/ruby/1.8/net/http.rb:1556:in `read_status_line': wrong status line: "Date,Open,High,Low,Close,Volume,Adj Close" (Net::HTTPBadResponse) from /usr/lib/ruby/1.8/net/http.rb:1538:in `read_new' from /usr/lib/ruby/1.8/net/http.rb:833:in `request' from /usr/lib/ruby/1.8/net/http.rb:615:in `get' from r1test.rb:13:in `get_historical_data' from r1test.rb:12:in `start' from /usr/lib/ruby/1.8/net/http.rb:324:in `start' from r1test.rb:12:in `get_historical_data' from r1test.rb:18 -- Posted via http://www.ruby-forum.com/.