akezurel_scrape 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/akezurel_scrape.rb +58 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8aeea63ce8635d82e36f6ed68a4fe70332cd6e33d29a6bd0153cd1f423567250
|
4
|
+
data.tar.gz: 5b5f852a77803ab0f9a25b8a983722ec4d27b84888653c452d581ec910de1235
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '09cca0c08c36ff3087b36d28ccc7438a1b5743dcafa400ee84fa4997504d744422f71ce06b1c6a665ea6e751670f1ce01d74832cc0ce41e1a3fa12c6f5d83c4e'
|
7
|
+
data.tar.gz: 578991da1b3c5d97e22395e64cc77e75b311da160316125f077d681fcfe5f3fb57989fc048a855e89fbb4aaf69916e312d1c53939c3b76b845c2d45bd18a61a0
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Chanathip Thumkanon
|
3
|
+
# 6210546650
|
4
|
+
|
5
|
+
|
6
|
+
require 'Nokogiri'
|
7
|
+
require 'open-uri'
|
8
|
+
|
9
|
+
|
10
|
+
class AkezurelScrape
|
11
|
+
def initialize(url=nil)
|
12
|
+
if url == nil
|
13
|
+
@url = "https://www.set.or.th/set/companyhighlight.do?symbol=DELTA"
|
14
|
+
# @url = "https://www.set.or.th/set/companyhighlight.do?symbol=A"
|
15
|
+
else
|
16
|
+
@url = url
|
17
|
+
end
|
18
|
+
@doc = nil
|
19
|
+
@company = nil
|
20
|
+
@price = nil
|
21
|
+
@is_done_scrape = false
|
22
|
+
end
|
23
|
+
|
24
|
+
def do_scrape
|
25
|
+
@doc = Nokogiri::HTML(open(@url))
|
26
|
+
@company = @doc.css("h3").text
|
27
|
+
@doc.css("tr").each do |tr|
|
28
|
+
found = false
|
29
|
+
tr.children.each.with_index do |c,index|
|
30
|
+
if c.to_s.include? "สินทรัพย์รวม"
|
31
|
+
found = true
|
32
|
+
end
|
33
|
+
if found and index == 9
|
34
|
+
@price = c.text
|
35
|
+
found = false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
@is_done_scrape = true
|
40
|
+
end
|
41
|
+
|
42
|
+
def show_asset
|
43
|
+
if !@is_done_scrape
|
44
|
+
do_scrape
|
45
|
+
end
|
46
|
+
if @price == nil
|
47
|
+
puts "No total assets price found."
|
48
|
+
else
|
49
|
+
puts "#{@company} : #{@price}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
# s = AkezurelScrape. new
|
57
|
+
# # s.do_scrape
|
58
|
+
# s.show_asset
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: akezurel_scrape
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chanathip Thumkanon 6210546650
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-02-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Softspec KU lab subject assignment that scrapes a stock market url.
|
14
|
+
email: chanathip.thu@ku.th
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/akezurel_scrape.rb
|
20
|
+
homepage: https://rubygems.org/gems/akezurel_scrape
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubygems_version: 3.0.3
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: Stock market url scraper.
|
43
|
+
test_files: []
|