Class: Scraper
- Inherits:
-
Object
- Object
- Scraper
- Defined in:
- lib/makeup_maker/scraper.rb
Instance Attribute Summary collapse
-
#corp_info ⇒ Object
Returns the value of attribute corp_info.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
-
#stock_name ⇒ Object
Returns the value of attribute stock_name.
-
#stock_price ⇒ Object
Returns the value of attribute stock_price.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Attribute Details
#corp_info ⇒ Object
Returns the value of attribute corp_info.
2 3 4 |
# File 'lib/makeup_maker/scraper.rb', line 2 def corp_info @corp_info end |
#location ⇒ Object
Returns the value of attribute location.
2 3 4 |
# File 'lib/makeup_maker/scraper.rb', line 2 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/makeup_maker/scraper.rb', line 2 def name @name end |
#stock_name ⇒ Object
Returns the value of attribute stock_name.
2 3 4 |
# File 'lib/makeup_maker/scraper.rb', line 2 def stock_name @stock_name end |
#stock_price ⇒ Object
Returns the value of attribute stock_price.
2 3 4 |
# File 'lib/makeup_maker/scraper.rb', line 2 def stock_price @stock_price end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/makeup_maker/scraper.rb', line 2 def url @url end |
Class Method Details
.name ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/makeup_maker/scraper.rb', line 4 def self.name makers = [] doc = Nokogiri::HTML(open("https://finance.yahoo.com/sector/consumer_goods")) makers_name = doc.search("div tbody tr td")[191].text makers_1_name = doc.search("div tbody tr td")[621].text makers << makers_name makers << makers_1_name end |
.scrape_coty ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/makeup_maker/scraper.rb', line 32 def self.scrape_coty docs_1 = Nokogiri::HTML(open("https://finance.yahoo.com/quote/COTY/profile?p=COTY")) doc = Nokogiri::HTML(open("https://finance.yahoo.com/sector/consumer_goods")) #instantiate new object maker = self.new maker.stock_name = doc.search("div tbody td a[title]")[62].text maker.stock_price = doc.search("tr td span")[189].text.to_i maker.location = docs_1.search("div p")[0].text[16...28] maker.url = docs_1.search("div p a")[1].text maker.corp_info = docs_1.search("div p")[2].text maker end |
.scrape_el ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/makeup_maker/scraper.rb', line 19 def self.scrape_el doc = Nokogiri::HTML(open("https://finance.yahoo.com/sector/consumer_goods")) docs = Nokogiri::HTML(open("https://finance.yahoo.com/quote/EL/profile?p=EL")) maker = self.new #instantiate new object maker.stock_name = doc.search("div tbody td a[title]")[19].text maker.stock_price = doc.search("div tbody td span")[19].values[1] maker.location = docs.search("div p")[0].text[16...28] maker.url = docs.search("div p a")[1].text maker.corp_info = docs.search("div p")[2].text maker end |
.scrape_info ⇒ Object
13 14 15 16 17 |
# File 'lib/makeup_maker/scraper.rb', line 13 def self.scrape_info makers_a = [] makers_a << self.scrape_el makers_a << self.scrape_coty end |