Class: SnesFinderCliApp::Amazon
- Inherits:
-
Object
- Object
- SnesFinderCliApp::Amazon
- Defined in:
- lib/snes_finder_cli_app/snes_finder.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
Returns the value of attribute doc.
-
#more_info ⇒ Object
Returns the value of attribute more_info.
-
#status ⇒ Object
Returns the value of attribute status.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize ⇒ Amazon
constructor
A new instance of Amazon.
- #scraper ⇒ Object
Constructor Details
#initialize ⇒ Amazon
Returns a new instance of Amazon.
28 29 30 |
# File 'lib/snes_finder_cli_app/snes_finder.rb', line 28 def initialize @url = "https://www.amazon.com/Super-NES-Classic/dp/B0721GGGS9/ref=sr_1_1?ie=UTF8&qid=1503878302&sr=8-1&keywords=snes+classic" end |
Instance Attribute Details
#doc ⇒ Object
Returns the value of attribute doc.
26 27 28 |
# File 'lib/snes_finder_cli_app/snes_finder.rb', line 26 def doc @doc end |
#more_info ⇒ Object
Returns the value of attribute more_info.
26 27 28 |
# File 'lib/snes_finder_cli_app/snes_finder.rb', line 26 def more_info @more_info end |
#status ⇒ Object
Returns the value of attribute status.
26 27 28 |
# File 'lib/snes_finder_cli_app/snes_finder.rb', line 26 def status @status end |
#url ⇒ Object
Returns the value of attribute url.
26 27 28 |
# File 'lib/snes_finder_cli_app/snes_finder.rb', line 26 def url @url end |
Instance Method Details
#scraper ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/snes_finder_cli_app/snes_finder.rb', line 32 def scraper browser = Watir::Browser.new :chrome, headless: true browser.goto @url @doc = Nokogiri::HTML.parse(browser.html) browser.close @more_info = @doc.css("#feature-bullets").text.gsub(/\t/,"").gsub(/\n{2,}/,"\n").strip @doc.css("#add-to-cart-button").empty? ? @status = "Out of Stock" : @status = @doc.css("#add-to-cart-button").attribute("value").value end |