class AkezurelScrape
Public Class Methods
new(url=nil)
click to toggle source
# File lib/akezurel_scrape.rb, line 11 def initialize(url=nil) if url == nil @url = "https://www.set.or.th/set/companyhighlight.do?symbol=DELTA" # @url = "https://www.set.or.th/set/companyhighlight.do?symbol=A" else @url = url end @doc = nil @company = nil @price = nil @is_done_scrape = false end
Public Instance Methods
do_scrape()
click to toggle source
# File lib/akezurel_scrape.rb, line 24 def do_scrape @doc = Nokogiri::HTML(open(@url)) @company = @doc.css("h3").text @doc.css("tr").each do |tr| found = false tr.children.each.with_index do |c,index| if c.to_s.include? "สินทรัพย์รวม" found = true end if found and index == 9 @price = c.text found = false end end end @is_done_scrape = true end
show_asset()
click to toggle source
# File lib/akezurel_scrape.rb, line 42 def show_asset if !@is_done_scrape do_scrape end if @price == nil puts "No total assets price found." else puts "#{@company} : #{@price}" end end