8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/set_scrub.rb', line 8
def scrapper
html = URI.open("https://www.set.or.th/set/commonslookup.do")
home = Nokogiri::HTML(html)
stock_listings = home.css("tr")[1..-1]
stock_pages = home.css("div.col-xs-12.padding-top-10.text-center.capital-letter").css("a")[0..-1]
stock_pages.each do |stock_paging|
url = "https://www.set.or.th" + stock_paging.attributes["href"].value
html = URI.open(url)
home = Nokogiri::HTML(html)
stock_listings = home.css("tr")[1..-1]
stock_listings.each do |stock_listing|
url = "https://www.set.or.th/set/companyhighlight.do?symbol=" + stock_listing.css("a")[0].text + "&ssoPageId=5&language=th&country=TH"
html = URI.open(url)
doc = Nokogiri::HTML(html)
print doc.css("h3").text + " : "
value = doc.css("tr").text.split("\n")[15]
if value != nil
print value.strip
end
puts ""
end
end
end
|