Class: KaopunSearch
- Inherits:
-
Object
- Object
- KaopunSearch
- Defined in:
- lib/kaopun_search.rb
Class Method Summary collapse
-
.get_all_link ⇒ Object
search all link.
-
.get_delta ⇒ Object
search only delta.
Class Method Details
.get_all_link ⇒ Object
search all link
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# 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 ⇒ Object
search only delta
10 11 12 13 14 15 |
# 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 |