closest_weightlifting_gem 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -13
- data/bin/console +2 -11
- data/closest_weightlifting_gem.gemspec +1 -1
- data/lib/closest_weightlifting_gem/cli.rb +63 -66
- data/lib/closest_weightlifting_gem/gym.rb +17 -10
- data/lib/closest_weightlifting_gem/scraper.rb +94 -41
- data/lib/closest_weightlifting_gem/version.rb +1 -1
- data/notes.md +9 -4
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c14f13107e2795302c5a22106b1bdc3818cde5ed
|
4
|
+
data.tar.gz: dff447ea0e068ebe463fb1987b410e9febe74d62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d3d695c3a5b3dc5c2a5b3b4b7beb7eacc2094f7ac986e783edd6483f6779fd752ad03a98917df59122482bad93286b59fd03336f45ad288261becb730c0392f
|
7
|
+
data.tar.gz: f21d93c40f5c4cf12be6d52eef04304ef1149f2708eabae1963785e545aa008014857b01b4d9f749b22beafd5b9172bba9bf5502a68d7e11015dc08b69527eeb
|
data/README.md
CHANGED
@@ -2,13 +2,6 @@
|
|
2
2
|
|
3
3
|
This application scrapes the [USA Weightlifting's Find a Club ](http://www.teamusa.org/usa-weightlifting/clubs-lwc/find-a-club) feature and builds a Gym object for each club, which includes some basic biographical information.
|
4
4
|
|
5
|
-
TODO:
|
6
|
-
---
|
7
|
-
* Implement proper options from CLI#show_gym
|
8
|
-
* show_gym page from #find_by_names menu should take it back to those search results instead of the state results
|
9
|
-
* Geocode gym addresses
|
10
|
-
* Implement user location input to find nearest gyms
|
11
|
-
|
12
5
|
## Installation
|
13
6
|
|
14
7
|
Add this line to your application's Gemfile:
|
@@ -25,15 +18,24 @@ Or install it yourself as:
|
|
25
18
|
|
26
19
|
$ gem install closest_weightlifting_gem
|
27
20
|
|
28
|
-
##
|
29
|
-
|
21
|
+
## Development
|
30
22
|
|
23
|
+
To interact with the command line interface, clone the repo locally and change directories into the new folder. Then you can run `bundle install` or `bin/setup` from the terminal prompt to install dependencies that aren't already on your system. Then, call the full program by typing `bin/closest-weightlifting-gem` into the prompt. Note: It scrapes everything up front so that I can query against the entire set of 1168 gyms (as of June 11 2016).
|
31
24
|
|
32
|
-
|
25
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment. From within this console, you can call `basic_setup` and it will scrape all the gyms in Florida, Illinois, and New York to add some data into the system.
|
33
26
|
|
34
|
-
|
27
|
+
TODO:
|
28
|
+
---
|
29
|
+
* DRY up Scraper class
|
30
|
+
* Hook up to ActiveRecord
|
31
|
+
* Geocode gym addresses
|
32
|
+
* Implement user location input to find nearest gyms
|
33
|
+
* Map
|
35
34
|
|
36
|
-
|
35
|
+
Done:
|
36
|
+
---
|
37
|
+
* Implement proper options from CLI#show_gym
|
38
|
+
* show_gym page from #find_by_names menu should take it back to those search results instead of the state results
|
37
39
|
|
38
40
|
## Contributing
|
39
41
|
|
@@ -43,4 +45,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/zacsco
|
|
43
45
|
## License
|
44
46
|
|
45
47
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
46
|
-
|
data/bin/console
CHANGED
@@ -2,24 +2,15 @@
|
|
2
2
|
|
3
3
|
require "bundler/setup"
|
4
4
|
require "closest_weightlifting_gem"
|
5
|
+
require 'pry'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
8
9
|
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require 'pry'
|
14
|
-
|
15
|
-
def reload!
|
16
|
-
load './lib/closest_weightlifting_gem.rb'
|
17
|
-
end
|
18
|
-
|
19
10
|
def basic_setup
|
20
11
|
["FL","IL","NY"].each do |state|
|
21
12
|
ClosestWeightliftingGem::Scraper.scrape_state_page(state)
|
22
13
|
end
|
23
14
|
end
|
24
15
|
|
25
|
-
Pry.start
|
16
|
+
Pry.start
|
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency "bundler", "~> 1.11"
|
31
31
|
spec.add_development_dependency "rake", "~> 10.0"
|
32
32
|
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
-
spec.add_development_dependency "pry", "~> 0.10.
|
33
|
+
spec.add_development_dependency "pry", "~> 0.10.4"
|
34
34
|
|
35
35
|
spec.add_dependency "nokogiri", "~> 1.6.7.2"
|
36
36
|
spec.add_dependency "require_all", "~> 1.3.3"
|
@@ -14,50 +14,12 @@ class ClosestWeightliftingGem::CLI
|
|
14
14
|
ClosestWeightliftingGem::Scraper.scrape_main
|
15
15
|
end
|
16
16
|
|
17
|
-
# Not implemented currently, but plan to introduce when I figure out geocoder
|
18
|
-
#
|
19
|
-
# def address_input
|
20
|
-
# puts <<-DOC.gsub /^\s*/, ''
|
21
|
-
# Please enter your address below and I'll find
|
22
|
-
# the closest weightlifting gym. (ex. 123 Main St. New York, NY)
|
23
|
-
# DOC
|
24
|
-
|
25
|
-
# address = gets.chomp
|
26
|
-
# end
|
27
|
-
|
28
17
|
def main_menu
|
29
18
|
puts "What do you want to do now?"
|
30
19
|
|
31
20
|
options(__method__)
|
32
21
|
end
|
33
22
|
|
34
|
-
def show_gyms(gyms)
|
35
|
-
width = 80
|
36
|
-
puts line
|
37
|
-
puts "OK, your search yielded #{gyms.size} gyms!\n"
|
38
|
-
puts "Here's the list: "
|
39
|
-
puts line
|
40
|
-
puts " Gym Name".ljust(width/2)+" City"
|
41
|
-
|
42
|
-
gyms.each_with_index do |gym, i|
|
43
|
-
puts "#{(i+1).to_s.rjust(3)}. #{gym.name.ljust(width/2)} #{gym.city}, #{gym.state}"
|
44
|
-
end
|
45
|
-
|
46
|
-
options(__method__, gyms)
|
47
|
-
end
|
48
|
-
|
49
|
-
def show_gym(gym)
|
50
|
-
ClosestWeightliftingGem::Scraper.scrape_attributes(gym) if !gym.coach
|
51
|
-
|
52
|
-
puts "Name: #{gym.name}"
|
53
|
-
puts "Address: #{gym.full_address}"
|
54
|
-
puts "Director: #{gym.director}"
|
55
|
-
puts "Coach: #{gym.coach}"
|
56
|
-
puts "Website: #{gym.website}"
|
57
|
-
|
58
|
-
options(__method__, gym)
|
59
|
-
end
|
60
|
-
|
61
23
|
def options(menu, data=nil)
|
62
24
|
menu = menu.to_s
|
63
25
|
|
@@ -84,31 +46,75 @@ class ClosestWeightliftingGem::CLI
|
|
84
46
|
when "show_gym"
|
85
47
|
puts line
|
86
48
|
puts <<-DOC.gsub(/^\s*/,'')
|
87
|
-
1. Open
|
88
|
-
2. Back to
|
89
|
-
|
90
|
-
|
49
|
+
1. Open in Google Maps
|
50
|
+
2. Back to Previous Search
|
51
|
+
2. Main menu
|
52
|
+
3. Exit
|
91
53
|
DOC
|
92
54
|
|
93
55
|
process_gym(data)
|
94
56
|
else
|
95
|
-
puts "
|
57
|
+
puts "What was that??"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Not implemented currently, but plan to introduce when I figure out geocoder
|
62
|
+
#
|
63
|
+
def address_input
|
64
|
+
puts <<-DOC.gsub /^\s*/, ''
|
65
|
+
Please enter your address below and I'll find
|
66
|
+
the closest weightlifting gym. (ex. 123 Main St. New York, NY)
|
67
|
+
DOC
|
68
|
+
|
69
|
+
address = gets.chomp
|
70
|
+
end
|
71
|
+
|
72
|
+
def show_gyms(gyms)
|
73
|
+
width = 80
|
74
|
+
puts "="*width
|
75
|
+
puts "OK, your search yielded #{gyms.size} gyms!\n"
|
76
|
+
puts "Here's the list: "
|
77
|
+
puts "="*width
|
78
|
+
puts " Gym Name".ljust(width/2)+" City"
|
79
|
+
|
80
|
+
gyms.each_with_index do |gym, i|
|
81
|
+
puts "#{(i+1).to_s.rjust(3)}. #{gym.name.ljust(width/2)} #{gym.city}, #{gym.state}"
|
82
|
+
end
|
83
|
+
|
84
|
+
options(__method__, gyms)
|
85
|
+
end
|
86
|
+
|
87
|
+
def show_gym(gym)
|
88
|
+
puts "Name: #{gym.name}"
|
89
|
+
puts "Address: #{gym.full_address}"
|
90
|
+
puts "Director: #{gym.director}"
|
91
|
+
puts "Phone: #{gym.phone}"
|
92
|
+
|
93
|
+
options(__method__, gym)
|
94
|
+
end
|
95
|
+
|
96
|
+
def open_in_google_maps(gym)
|
97
|
+
if gym.full_address
|
98
|
+
system("open", "http://maps.google.com/?q=#{gym.full_address}")
|
99
|
+
else
|
100
|
+
puts "Sorry, that gym doesn't have an address listed.\n\n\n\n"
|
101
|
+
show_gym(gym)
|
96
102
|
end
|
97
103
|
end
|
98
104
|
|
99
105
|
def open_in_browser(gym)
|
100
106
|
if gym.website == "none"
|
101
|
-
puts "Sorry, that gym doesn't have a website. :("
|
107
|
+
puts "Sorry, that gym doesn't have a website. :(\n\n\n"
|
102
108
|
elsif !gym.website.include?("http")
|
103
109
|
system("open", "http://#{gym.website}")
|
104
|
-
else
|
110
|
+
else
|
105
111
|
system("open", "#{gym.website}")
|
106
112
|
end
|
107
113
|
end
|
108
114
|
|
109
115
|
def process_main
|
110
116
|
input = nil
|
111
|
-
|
117
|
+
|
112
118
|
while input != "exit"
|
113
119
|
input = gets.strip.downcase
|
114
120
|
|
@@ -123,12 +129,8 @@ class ClosestWeightliftingGem::CLI
|
|
123
129
|
show_gyms(ClosestWeightliftingGem::Gym.find_by_name(search_term))
|
124
130
|
when "3"
|
125
131
|
good_bye
|
126
|
-
|
127
|
-
exit
|
128
132
|
when "exit"
|
129
133
|
good_bye
|
130
|
-
|
131
|
-
exit
|
132
134
|
else
|
133
135
|
puts "I didn't understand that, please try again."
|
134
136
|
end
|
@@ -137,14 +139,15 @@ class ClosestWeightliftingGem::CLI
|
|
137
139
|
|
138
140
|
def process_gyms(gyms)
|
139
141
|
input = nil
|
140
|
-
|
142
|
+
|
141
143
|
until input == "exit"
|
142
144
|
input = gets.strip.downcase
|
145
|
+
|
143
146
|
case input
|
144
147
|
when "1"
|
145
148
|
puts "Select a gym by the number:"
|
146
149
|
gym_num = gets.chomp.to_i - 1
|
147
|
-
|
150
|
+
|
148
151
|
show_gym(gyms[gym_num])
|
149
152
|
when "2"
|
150
153
|
show_gyms(gyms)
|
@@ -152,12 +155,8 @@ class ClosestWeightliftingGem::CLI
|
|
152
155
|
main_menu
|
153
156
|
when "4"
|
154
157
|
good_bye
|
155
|
-
|
156
|
-
exit
|
157
158
|
when "exit"
|
158
159
|
good_bye
|
159
|
-
|
160
|
-
exit
|
161
160
|
else
|
162
161
|
puts "I didn't understand that, please try again."
|
163
162
|
end
|
@@ -166,26 +165,22 @@ class ClosestWeightliftingGem::CLI
|
|
166
165
|
|
167
166
|
def process_gym(gym)
|
168
167
|
input = nil
|
169
|
-
|
168
|
+
|
170
169
|
until input == "exit"
|
171
170
|
input = gets.strip.downcase
|
171
|
+
|
172
172
|
case input
|
173
173
|
when "1"
|
174
|
-
|
175
|
-
|
176
|
-
options("show_gym", gym)
|
174
|
+
open_in_google_maps(gym)
|
175
|
+
process_gym(gym)
|
177
176
|
when "2"
|
178
|
-
show_gyms(ClosestWeightliftingGem::Gym.
|
177
|
+
show_gyms(ClosestWeightliftingGem::Gym.find_by_last_search)
|
179
178
|
when "3"
|
180
179
|
main_menu
|
181
180
|
when "4"
|
182
181
|
good_bye
|
183
|
-
|
184
|
-
exit
|
185
182
|
when "exit"
|
186
183
|
good_bye
|
187
|
-
|
188
|
-
exit
|
189
184
|
else
|
190
185
|
puts "I didn't understand that, please try again."
|
191
186
|
end
|
@@ -199,5 +194,7 @@ class ClosestWeightliftingGem::CLI
|
|
199
194
|
|
200
195
|
def good_bye
|
201
196
|
puts "Adios friend. Hope you come back to lift weights again!"
|
197
|
+
|
198
|
+
exit
|
202
199
|
end
|
203
|
-
end
|
200
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'pry'
|
2
|
+
|
1
3
|
class ClosestWeightliftingGem::Gym
|
2
4
|
attr_accessor :name,
|
3
5
|
:full_address,
|
@@ -7,8 +9,6 @@ class ClosestWeightliftingGem::Gym
|
|
7
9
|
:zipcode,
|
8
10
|
:phone,
|
9
11
|
:director,
|
10
|
-
:coach,
|
11
|
-
:usaw_url,
|
12
12
|
:website
|
13
13
|
|
14
14
|
@@all = []
|
@@ -25,7 +25,11 @@ class ClosestWeightliftingGem::Gym
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def full_address
|
28
|
-
|
28
|
+
if street.nil?
|
29
|
+
nil
|
30
|
+
else
|
31
|
+
"#{street}, #{city}, #{state} #{zipcode}"
|
32
|
+
end
|
29
33
|
end
|
30
34
|
|
31
35
|
def self.all
|
@@ -45,26 +49,29 @@ class ClosestWeightliftingGem::Gym
|
|
45
49
|
end
|
46
50
|
|
47
51
|
def self.weird_gyms
|
48
|
-
self.all.find_all do |g|
|
49
|
-
g.phone
|
52
|
+
self.all.find_all do |g|
|
53
|
+
g.phone.nil? || g.street.nil? || g.name.nil? || g.city.nil?
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
53
57
|
def self.find_by_name(input)
|
54
58
|
self.searches << { method: __method__, value: input }
|
55
59
|
|
56
|
-
|
57
|
-
gym.name.upcase.include?(input.upcase)
|
58
|
-
end
|
60
|
+
self.all.find_all { |gym| gym.name.upcase.include?(input.upcase) }
|
59
61
|
end
|
60
62
|
|
61
63
|
def self.find_by_state(state)
|
62
64
|
self.searches << { method: __method__, value: state }
|
63
|
-
|
65
|
+
|
64
66
|
self.all.find_all { |gym| gym.state == state.upcase }
|
65
67
|
end
|
66
68
|
|
69
|
+
def self.find_by_last_search
|
70
|
+
last_search = @@searches.last
|
71
|
+
self.send(last_search[:method], last_search[:value])
|
72
|
+
end
|
73
|
+
|
67
74
|
def self.count_by_state
|
68
75
|
self.all.inject(Hash.new(0)) { |total, gym| total[gym.state] += 1 ; total }
|
69
76
|
end
|
70
|
-
end
|
77
|
+
end
|
@@ -1,73 +1,126 @@
|
|
1
|
-
|
1
|
+
require 'pry'
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
require 'uri'
|
2
5
|
|
6
|
+
class ClosestWeightliftingGem::Scraper
|
3
7
|
BASE_URL = "https://webpoint.usaweightlifting.org/wp15/Companies/"
|
4
8
|
|
9
|
+
def self.get_state_abbreviations(index)
|
10
|
+
index.search("select#CompanyState").children[2..-1].collect { |child| child.attr("value") }
|
11
|
+
end
|
12
|
+
|
5
13
|
def self.scrape_main
|
6
14
|
puts "Fetching index..."
|
7
|
-
index = Nokogiri::HTML(open("#{BASE_URL}/Clubs.wp?frm=t"))
|
15
|
+
index = Nokogiri::HTML(open("#{BASE_URL}/Clubs.wp?frm=t&RF=Zp%2CST"))
|
8
16
|
|
9
17
|
get_state_abbreviations(index).each { |state| scrape_state_page(state) }
|
10
18
|
|
11
19
|
puts "\n\nSorry that took so long."
|
12
20
|
end
|
13
21
|
|
22
|
+
# Form Data
|
23
|
+
# do I need cookies, etc now?
|
14
24
|
def self.scrape_state_page(state)
|
15
25
|
puts "Fetching gym data in #{state}..."
|
16
|
-
|
26
|
+
data = {
|
27
|
+
'wp_ClientOrgID' => '',
|
28
|
+
'CompanyParentID' => '',
|
29
|
+
'CompanyName' => '',
|
30
|
+
'CompanyState' => state,
|
31
|
+
'geo_Zip' => '',
|
32
|
+
'geo_Miles' => 25,
|
33
|
+
'submit' => 'Go'
|
34
|
+
}
|
17
35
|
|
18
|
-
|
19
|
-
|
20
|
-
|
36
|
+
url = URI("#{BASE_URL}/Clubs.wp?frm=t&RF=Zp%2CST")
|
37
|
+
http = Net::HTTP.new(url.host, url.port)
|
38
|
+
http.use_ssl = true
|
39
|
+
request = Net::HTTP::Post.new(url)
|
40
|
+
request["Content-Type"] = 'application/x-www-form-urlencoded'
|
41
|
+
request["cache-control"] = 'no-cache'
|
42
|
+
request.body = "wp_ClientOrgID=&CompanyParentID=&CompanyName=&CompanyState=#{state}&geo_Zip=&geo_Miles=25&submit=Go"
|
43
|
+
response = http.request(request)
|
44
|
+
state_doc = Nokogiri::HTML(response.read_body)
|
21
45
|
|
22
|
-
state_doc.search("
|
46
|
+
state_doc.search("#wp_Clubs li").each do |gym_row|
|
47
|
+
details = extract_details(gym_row.search("p")[0])
|
23
48
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
:usaw_url => gym_row.search("a").first.attr("onclick").match(/\/V.+true/)[0]
|
35
|
-
})
|
36
|
-
end
|
49
|
+
ClosestWeightliftingGem::Gym.new({
|
50
|
+
:name => gym_row.search("h3").text.strip,
|
51
|
+
:street => details[:street], #gym_row.search("p").children[0].to_s,
|
52
|
+
:city => details[:city], #gym_row.search("p").children[2].to_s.split(/\W+/)[0],
|
53
|
+
:state => state,
|
54
|
+
:zipcode => details[:zipcode], #gym_row.search("p").children[2].to_s.split(/\W+/)[-1],
|
55
|
+
:phone => details[:phone], #gym_row.search("p").children[4].to_s,
|
56
|
+
:website => details[:website],
|
57
|
+
:director => details[:director]
|
58
|
+
})
|
37
59
|
end
|
38
60
|
end
|
39
61
|
|
40
62
|
def self.scrape_gym_page(gym_row)
|
41
63
|
gym_doc = Nokogiri::HTML(open("#{BASE_URL + gym_row.search("a").first.attr("onclick").match(/\/V.+true/)[0]}"))
|
42
|
-
|
64
|
+
|
43
65
|
ClosestWeightliftingGem::Gym.new({
|
44
|
-
:name => gym_doc.search("
|
45
|
-
:street => gym_doc.search("
|
46
|
-
:city =>
|
47
|
-
:state =>
|
48
|
-
:zipcode =>
|
49
|
-
:phone =>
|
66
|
+
:name => gym_doc.search("h3").text,
|
67
|
+
:street => gym_doc.search("p").children[0].to_s,
|
68
|
+
:city => gym_row.search("p").children[2].to_s.split(/\W+/)[0],
|
69
|
+
:state => gym_row.search("p").children[2].to_s.split(/\W+/)[1],
|
70
|
+
:zipcode => gym_row.search("p").children[2].to_s.split(/\W+/)[-1],
|
71
|
+
:phone => gym_row.search("p").children[4].to_s,
|
50
72
|
:director => gym_doc.search(".fe_big_row:nth-child(2) td+ td").text,
|
51
73
|
:coach => gym_doc.search(".fe_big_row+ .fe_big_row td+ td").text,
|
52
74
|
:website => gym_doc.text.split("site:")[1].split("\r").first[1..-1],
|
53
75
|
:usaw_url => gym_row.search("a").first.attr("onclick").match(/\/V.+true/)[0]
|
54
76
|
})
|
55
|
-
|
56
77
|
end
|
57
78
|
|
58
|
-
def self.
|
59
|
-
|
79
|
+
def self.extract_details(info_div)
|
80
|
+
details = {
|
81
|
+
"street": "",
|
82
|
+
"city": "",
|
83
|
+
"state": "",
|
84
|
+
"zipcode": "",
|
85
|
+
"phone": "",
|
86
|
+
"website": "",
|
87
|
+
"director": ""
|
88
|
+
}
|
60
89
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
90
|
+
begin
|
91
|
+
aa = info_div.children.select { |el| !["br", "b"].include?(el.name) }
|
92
|
+
case aa.length
|
93
|
+
when 1
|
94
|
+
details[:phone] = aa[0].text
|
95
|
+
when 3
|
96
|
+
details[:phone] = aa[0].text
|
97
|
+
details[:director] = aa[1].text
|
98
|
+
when 4
|
99
|
+
details[:phone] = aa[0].text
|
100
|
+
details[:website] = aa[1].text
|
101
|
+
details[:director] = aa[2].text
|
102
|
+
else
|
103
|
+
if aa[1].text.include?(", ")
|
104
|
+
city, state_zip = aa[1].text.split(", ")
|
105
|
+
else
|
106
|
+
city, state_zip = aa[2].text.split(", ")
|
107
|
+
end
|
68
108
|
|
69
|
-
|
70
|
-
|
71
|
-
|
109
|
+
state, empty, zip = state_zip.split(/[[:space:]]/)
|
110
|
+
details[:street] = aa[0].text
|
111
|
+
details[:city] = city
|
112
|
+
details[:state] = state
|
113
|
+
details[:zipcode] = zip
|
114
|
+
details[:phone] = aa[2].text
|
115
|
+
details[:website] = aa[3]["href"]
|
116
|
+
details[:director] = aa[4].text
|
117
|
+
end
|
118
|
+
rescue StandardError => e
|
119
|
+
puts "[ERROR] extracting details from: #{aa}"
|
120
|
+
puts "[ERROR] #{e}"
|
121
|
+
end
|
72
122
|
|
73
|
-
|
123
|
+
details.each { |k, v| details[k] = "" if v.nil? }
|
124
|
+
details
|
125
|
+
end
|
126
|
+
end
|
data/notes.md
CHANGED
@@ -1,11 +1,18 @@
|
|
1
|
-
ToDo:
|
1
|
+
# ToDo:
|
2
|
+
1. Website redesign has caused the scraping to fail.
|
3
|
+
* ~~.scrape_main to scrape the correct address~~
|
4
|
+
* Update gem versions!!!
|
5
|
+
* State pages have changed slightly in HTML structure and I need to identify
|
6
|
+
those new element selectors
|
2
7
|
|
8
|
+
|
9
|
+
## Legacy Notes:
|
3
10
|
Update Gemspec ToDos
|
4
11
|
2. Start with project structure
|
5
12
|
3. Start with entry point - file run (bin/closest-weightlifting-gem)
|
6
13
|
4. Build to CLI interface
|
7
14
|
5. Stub out interface
|
8
|
-
6. Start
|
15
|
+
6. Start making things real
|
9
16
|
7. Discover objects
|
10
17
|
8. Program
|
11
18
|
|
@@ -33,5 +40,3 @@ open to web page or google maps
|
|
33
40
|
|
34
41
|
Basic URI for accessing each state's individual page
|
35
42
|
https://webpoint.usaweightlifting.org/wp15/Companies/Clubs.wp?frm=t&CompanyValue=#{state}
|
36
|
-
|
37
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: closest_weightlifting_gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zacscodingclub
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.10.
|
61
|
+
version: 0.10.4
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.10.
|
68
|
+
version: 0.10.4
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: nokogiri
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
156
|
version: '0'
|
157
157
|
requirements: []
|
158
158
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.
|
159
|
+
rubygems_version: 2.6.13
|
160
160
|
signing_key:
|
161
161
|
specification_version: 4
|
162
162
|
summary: USA Weighlifting Club Gyms
|