class KaopunSearch
Public Class Methods
get_all_link()
click to toggle source
search all link
# File lib/kaopun_search.rb, line 18 def self.get_all_link all_letter = (10...36).map{ |i| i.to_s 36 } link = "https://www.set.or.th/set/commonslookup.do?" all_letter.insert(0,"NUMBER") all_letter.each do |letter| link = "https://www.set.or.th/set/commonslookup.do?language=th&country=TH&prefix=#{letter}" doc = Nokogiri::HTML(URI.open(link)) doc.css("tr a").each do |element| a_tag = element["href"] a_tag["profile"] = "highlight" link_to_each_page = "https://www.set.or.th/#{a_tag}" page = Nokogiri::HTML(URI.open(link_to_each_page)) asset_tri_3 = page.css("tr")[2].css("td")[-2].text name = page.css("h3").text puts "#{name} : #{asset_tri_3}" end end end
get_delta()
click to toggle source
search only delta
# File lib/kaopun_search.rb, line 10 def self.get_delta doc = Nokogiri::HTML(URI.open("https://www.set.or.th/set/companyprofile.do?symbol=DELTA")) doc.css("h3").each do |link| puts link.content end end