Class: Scraper

Inherits:
Object
  • Object
show all
Defined in:
lib/makeup_maker/scraper.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#corp_infoObject

Returns the value of attribute corp_info.



2
3
4
# File 'lib/makeup_maker/scraper.rb', line 2

def corp_info
  @corp_info
end

#locationObject

Returns the value of attribute location.



2
3
4
# File 'lib/makeup_maker/scraper.rb', line 2

def location
  @location
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/makeup_maker/scraper.rb', line 2

def name
  @name
end

#stock_nameObject

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_priceObject

Returns the value of attribute stock_price.



2
3
4
# File 'lib/makeup_maker/scraper.rb', line 2

def stock_price
  @stock_price
end

#urlObject

Returns the value of attribute url.



2
3
4
# File 'lib/makeup_maker/scraper.rb', line 2

def url
  @url
end

Class Method Details

.nameObject



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_cotyObject



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_elObject



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_infoObject



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