store_list_scraper 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/Gemfile.lock +1 -1
- data/lib/.DS_Store +0 -0
- data/lib/storeListScraper/cli.rb +17 -3
- data/lib/storeListScraper/csv_manage.rb +17 -2
- data/lib/storeListScraper/update_scraper.rb +8 -7
- data/lib/storeListScraper/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92ed0896efae35de12e0fdc9721b35bb4c87b10f67e41ae9b8c2c9a50c18d8c9
|
4
|
+
data.tar.gz: c149378f7140be688d5235e89938999c4b31a3c9cf99161f5f6b4abf88a74a8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c726a4590d15e8a03cdd2b1416a1db00e07a6f8a473db102d65716e63b657f317b85ed67353730e5ae736d831143c06181930fd5422831cf6a7dcadc97425ee
|
7
|
+
data.tar.gz: 866d6560cc321744cd27ed56054a6bc624dd5cefcfa499c48f08335deb9f797a11859e68245606d32a6b27b06f4f9aac7128ce1b93cdeafd3370506f05b852ca
|
data/.DS_Store
CHANGED
Binary file
|
data/Gemfile.lock
CHANGED
data/lib/.DS_Store
ADDED
Binary file
|
data/lib/storeListScraper/cli.rb
CHANGED
@@ -56,11 +56,11 @@ class ListScraper::CLI
|
|
56
56
|
when 1
|
57
57
|
puts "Please type letter(s) you want at the START of the business name:"
|
58
58
|
ListScraper::CSVmanager.list_view_by_letter(gets.strip)
|
59
|
-
|
59
|
+
list_validation
|
60
60
|
when 2
|
61
61
|
puts "Please type the keyword as you expect to see it in the business name.\n(example: 'Jimmy's Pizza' contains 'Pizza'"
|
62
62
|
ListScraper::CSVmanager.list_view_by_search(gets.strip)
|
63
|
-
|
63
|
+
list_validation
|
64
64
|
when 3
|
65
65
|
menu
|
66
66
|
else
|
@@ -69,11 +69,25 @@ class ListScraper::CLI
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
+
def list_validation
|
73
|
+
puts "\nSelect the number next to the business name you want to scrape\n OR type 'menu' to return to main menu."
|
74
|
+
input = gets.strip
|
75
|
+
if input == "menu"
|
76
|
+
menu
|
77
|
+
elsif ListScraper::CSVmanager.search_results[input.to_i] != nil
|
78
|
+
puts "Confirm you want to scrape (y/n):\n#{ListScraper::CSVmanager.search_results[input.to_i][0]}"
|
79
|
+
gets.strip.downcase == 'y' ? scrape(ListScraper::CSVmanager.search_results[input.to_i][1]): list_validation
|
80
|
+
else
|
81
|
+
puts "\n(ರ_ರ)\nThat is not a valid input.."
|
82
|
+
list_validation
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
72
86
|
def scrape(link)
|
73
87
|
a = ListScraper::LocationScraper.new("#{ListScraper::LocationScraper.base}#{link}")
|
74
88
|
a.page_scrape(a.link)
|
75
89
|
a.clean_out
|
76
|
-
puts "\n( ◕‿◕)\nI found #{a.loc_pages.length} locations
|
90
|
+
puts "\n( ◕‿◕)\nI found #{a.loc_pages.length} locations for this business.\nWould you like to export? (y/n)"
|
77
91
|
confirmation = gets.strip
|
78
92
|
if confirmation == 'y'
|
79
93
|
puts "\n(°ロ°)☝\nWhat would you like to name the file?"
|
@@ -1,5 +1,6 @@
|
|
1
1
|
|
2
2
|
class ListScraper::CSVmanager
|
3
|
+
@@search_results = {}
|
3
4
|
|
4
5
|
def self.locations_export(name)
|
5
6
|
c = CSV.open("#{name}.csv", "w")
|
@@ -18,11 +19,25 @@ class ListScraper::CSVmanager
|
|
18
19
|
|
19
20
|
def self.list_view_by_letter(letter)
|
20
21
|
g = CSV.read("./lib/storeListScraper/business_list.csv").select {|row| row[0].downcase.start_with?("#{letter.downcase}")}
|
21
|
-
g
|
22
|
+
ListScraper::CSVmanager.list_view_selection(g)
|
22
23
|
end
|
23
24
|
|
24
25
|
def self.list_view_by_search(word)
|
25
26
|
g = CSV.read("./lib/storeListScraper/business_list.csv").select {|row| row[0].downcase.include?("#{word.downcase}")}
|
26
|
-
g
|
27
|
+
ListScraper::CSVmanager.list_view_selection(g)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.list_view_selection(g)
|
31
|
+
@@search_results.clear
|
32
|
+
i = 1
|
33
|
+
g.each do |item|
|
34
|
+
puts "#{i}: #{item[0]}"
|
35
|
+
@@search_results[i] = item
|
36
|
+
i += 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.search_results
|
41
|
+
@@search_results
|
27
42
|
end
|
28
43
|
end
|
@@ -6,9 +6,9 @@ class ListScraper::UpdateScraper
|
|
6
6
|
def initialize
|
7
7
|
@base = 'https://storefound.org/'
|
8
8
|
@letters = [] #array of links for each letter group
|
9
|
-
|
10
|
-
File.delete('./lib/
|
11
|
-
@list = CSV.open("./lib/
|
9
|
+
@@pages = [] #array to store pages for each letter
|
10
|
+
File.delete('./lib/business_list.csv') if File.exist?('./lib/business_list.csv')
|
11
|
+
@list = CSV.open("./lib/storeListScraper/business_list.csv", "w")
|
12
12
|
@list << ["Company Name", "link"] #headers
|
13
13
|
update
|
14
14
|
end
|
@@ -32,20 +32,21 @@ class ListScraper::UpdateScraper
|
|
32
32
|
|
33
33
|
def pages_scrape(letter_link)
|
34
34
|
#scrape all page links for each letter group
|
35
|
-
|
35
|
+
@@pages.clear
|
36
36
|
doc = Nokogiri::HTML5(URI.open("#{@base}#{letter_link}"))
|
37
37
|
doc.css('.pagination a').each do |lk|
|
38
|
-
|
38
|
+
@@pages << lk.attribute('href').text
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
def update_business_list
|
43
43
|
#scrape all business names and corresponding links
|
44
|
-
|
45
|
-
doc = Nokogiri::HTML5(URI.open("#{@base}#{
|
44
|
+
@@pages.each do |h|
|
45
|
+
doc = Nokogiri::HTML5(URI.open("#{@base}#{h}"))
|
46
46
|
j = doc.css('.main-block .col-half a').each do |biz|
|
47
47
|
@list << [biz.text, biz.attribute('href').text]
|
48
48
|
end
|
49
49
|
end
|
50
|
+
@@pages.clear
|
50
51
|
end
|
51
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: store_list_scraper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- itsmattpaw
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- LICENSE.txt
|
97
97
|
- README.md
|
98
98
|
- Rakefile
|
99
|
+
- lib/.DS_Store
|
99
100
|
- lib/List_Scraper.rb
|
100
101
|
- lib/storeListScraper/business_list.csv
|
101
102
|
- lib/storeListScraper/cli.rb
|