class SetStock
Public Class Methods
stocks()
click to toggle source
# File lib/set_stock.rb, line 8 def self.stocks alpha = *('A'..'Z').each do|i| puts alpha html = URI.open("https://www.set.or.th/set/commonslookup.do?language=th&country=TH&prefix="+i) response = Nokogiri::HTML(html) link = response.css("td a").each do |newlink| temp = newlink.attributes["href"].value temp = temp.gsub('profile','highlight') temp2="https://www.set.or.th"+temp for_link=URI.open(temp2) for_response = Nokogiri::HTML(for_link) company = for_response.css("h3").text assert = for_response.css("td[6]").first if assert == nil or assert.text.gsub("\u00A0", '') == "" assert = for_response.css("td[5]").first if assert == nil or assert.text.gsub("\u00A0", '') == "" assert = for_response.css("td[4]").first if assert == nil or assert.text.gsub("\u00A0", '') == "" assert = for_response.css("td[3]").first if assert == nil or assert.text.gsub("\u00A0", '') == "" assert = for_response.css("td[2]").first if assert == nil or assert.text.gsub("\u00A0", '') == "" assert = "not found" end end end end end puts company+" : "+assert end end end