newegg_scraper_chsbr 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbfd1d76149f6e24674933978bc42dfed9c4793b07ede185dd890a9624ac8259
|
4
|
+
data.tar.gz: dcf10106484e843c95d888d267725e8d3cee154a78ae8014c141baf9a160495b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6eedd9aae8b3c008bb8485e882e24322d7b76ac61245f4690dd43772816f72e5a1b5be2ab7538be22c6fc643ab096a4f6530db673c0a04c2611e74fd5eaaec5b
|
7
|
+
data.tar.gz: d4d473f51c977978959b4dd7e32a91938cb626bd90b2cb8cd4d83e9e6ea08136747b658ce45f9beefab02aa73445683ef177274f1ab30c659136f42637791388
|
@@ -21,7 +21,7 @@ class NeweggScraperChsbr::CLI
|
|
21
21
|
NeweggScraperChsbr::Cpu.display_cpu(@user)
|
22
22
|
@user.choose_cpu
|
23
23
|
NeweggScraperChsbr::Cpu.display_cpu_with_extras(@user)
|
24
|
-
puts "If you would like to
|
24
|
+
puts "If you would like to restart the program please enter : #{@counter}.\nTo exit type n or exit."
|
25
25
|
@counter = gets.strip
|
26
26
|
corr_input = control_bool
|
27
27
|
while corr_input
|
@@ -44,7 +44,6 @@ class NeweggScraperChsbr::CLI
|
|
44
44
|
@cpu_make = gets.strip
|
45
45
|
not_found = cpu_make_bool
|
46
46
|
while not_found
|
47
|
-
puts "\n\n\n\n THIS IS CPU_MAKE: #{@cpu_make}\n\n\n IS THIS TRUE?: #{!@cpu_make.include?("x") || !@cpu_make.include?("a") || !@cpu_make.include?("i") || @cpu_make == nil }\n"
|
48
47
|
puts "Are you searching for Intel or AMD?"
|
49
48
|
puts "Please put i for Intel, or a for AMD."
|
50
49
|
puts "Please put x for either."
|
@@ -85,15 +84,17 @@ class NeweggScraperChsbr::CLI
|
|
85
84
|
puts "$500.50, please enter as 501, or 500 to stay below budget."
|
86
85
|
@max_price = gets.strip
|
87
86
|
end
|
88
|
-
|
89
|
-
puts "Please use the same format as above."
|
90
|
-
@min_price = gets.strip
|
91
|
-
while @min_price.to_i <= 0 || @min_price.to_i >= @max_price.to_i || @min_price.include?("$") || @min_price.include?(".") || @min_price == nil
|
87
|
+
if @max_price.to_i != 0
|
92
88
|
puts "Please enter the minimum you would spend on a CPU."
|
93
89
|
puts "Please use the same format as above."
|
94
90
|
@min_price = gets.strip
|
91
|
+
|
92
|
+
while @min_price.to_i <= 0 || @min_price.to_i >= @max_price.to_i || @min_price.include?("$") || @min_price.include?(".") || @min_price == nil
|
93
|
+
puts "Please enter the minimum you would spend on a CPU."
|
94
|
+
puts "Please use the same format as above."
|
95
|
+
@min_price = gets.strip
|
96
|
+
end
|
95
97
|
end
|
96
|
-
|
97
98
|
end
|
98
99
|
def control_bool
|
99
100
|
if @counter.include?("y")
|
@@ -4,7 +4,7 @@ class NeweggScraperChsbr::Scraper
|
|
4
4
|
|
5
5
|
URL = "https://www.newegg.com/p/pl?d=cpu"
|
6
6
|
def initialize(url = URL)
|
7
|
-
@xml_obj = Nokogiri::HTML(open(url)) # This opens the URL with open-uri, then parses it as an XML Object
|
7
|
+
@xml_obj = Nokogiri::HTML(URI.open(url)) # This opens the URL with open-uri, then parses it as an XML Object
|
8
8
|
end
|
9
9
|
|
10
10
|
|
@@ -9,13 +9,21 @@ class NeweggScraperChsbr::User
|
|
9
9
|
end
|
10
10
|
def choose_cpu
|
11
11
|
puts "Please enter the number of the CPU you'd like to see more about."
|
12
|
-
chosen = gets.strip
|
13
|
-
|
12
|
+
chosen = gets.strip
|
13
|
+
while !is_numeric?(chosen)
|
14
|
+
puts "Please enter the number of the CPU you'd like to see more about."
|
15
|
+
chosen = gets.strip
|
16
|
+
end
|
17
|
+
@chosen_cpu << chosen.to_i
|
14
18
|
puts "Would you like to see more about another CPU?\nEnter y to do so.\nEnter n to see details about the chosen CPU(s)"
|
15
19
|
input = gets.strip
|
20
|
+
|
16
21
|
if input == 'y'
|
17
22
|
choose_cpu
|
18
23
|
end
|
19
24
|
|
20
25
|
end
|
26
|
+
def is_numeric?(obj)
|
27
|
+
obj.match(/\A[^+-]?\d+?(\^.\d+)?\Z/) == nil ? false : true
|
28
|
+
end
|
21
29
|
end
|