class Object
Public Instance Methods
output_each(xnode)
click to toggle source
# File start_me.rb, line 16 def output_each(xnode) symbol = xnode.children[1].text puts "#{symbol} : #{xnode.children[3].text} : #{retrieve_data_asset_value(symbol)}" end
retrieve_data_asset_value(symbol)
click to toggle source
# File start_me.rb, line 8 def retrieve_data_asset_value(symbol) url = "https://www.set.or.th/set/companyhighlight.do?symbol=#{symbol}" source = Net::HTTP.get(URI.parse(url)) doc = Nokogiri::HTML(source) last_asset_value = doc.xpath('//*[@id="maincontent"]').xpath('//div[@class="table-responsive"]//table//tbody').first.xpath("//tr").drop(2).first.children.reverse.drop(3).first.text last_asset_value == " " ? "No last assets value found!" : last_asset_value end