10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/Scraper.rb', line 10
def self.scrape_page(clinic_url = "http://callen-lorde.org/meet-our-providers/")
html = open(clinic_url)
doc = Nokogiri::HTML(html)
attr_hash = Hash.new
array_of_providers = Array.new
doc.css(".middleColumn_three").css('h3').each do |provider|
new_hash = Hash.new
name_qualification_title = provider.text.split(",")
new_hash[:name] = name_qualification_title[0].gsub(/\w+[MD]/, "").strip
new_hash[:qualification] = name_qualification_title[1].strip
if name_qualification_title[2] != nil
new_hash[:title] = name_qualification_title[2].strip
end
array_of_providers << new_hash
end
i = 0
doc.css(".middleColumn_three").css('ul').each do |provider|
team_specialties_languanges = provider.text.split("\n").reject { |n| n == "" }
team_specialties_languanges = team_specialties_languanges.map do |ele|
ele.gsub(/\w+[:]/, "").strip
end
if team_specialties_languanges.size == 2
array_of_providers[i][:specialties] = team_specialties_languanges[0].strip
array_of_providers[i][:languages] = team_specialties_languanges[1]
else
array_of_providers[i][:team] = team_specialties_languanges[0]
array_of_providers[i][:specialties] = team_specialties_languanges[1]
array_of_providers[i][:languages] = team_specialties_languanges[2]
end
if i < 46
i += 1
end
end
array_of_providers.each do |provider|
Providers.new(provider)
end
end
|