Class: TSPScraper::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/tsp_scraper/client.rb

Class Method Summary collapse

Class Method Details

.scrape(start_date = Date.today.prev_month, end_date = Date.today, options = {}) ⇒ Object



25
26
27
28
# File 'lib/tsp_scraper/client.rb', line 25

def self.scrape(start_date = Date.today.prev_month, end_date = Date.today, options = {})
  raw = self.scrape_raw(start_date, end_date, options = {})
  TSPScraper::Converter.raw_csv_to_hash(raw)
end

.scrape_raw(start_date = Date.today.prev_month, end_date = Date.today, options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tsp_scraper/client.rb', line 9

def self.scrape_raw(start_date = Date.today.prev_month, end_date = Date.today, options = {})
  default_options = {
    query: {
      download: 1,
      startdate: start_date.strftime("%Y%m%d"),
      enddate: end_date.strftime("%Y%m%d"),
      format: "CSV",
      Lfunds: 1,
      InvFunds: 1
    }
  }
  options = default_options.merge(options)
  response = self.get("/getSharePrices.html", options)
  response.body.strip
end