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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/undercover_tourist_cli/scraper.rb', line 44
def self.attraction_details(attraction, city)
city.attractions.select.with_index do |val, index|
if val == attraction.name
@selected_attraction_url = city.urls[index]
attraction.url=(@selected_attraction_url)
end
end
attraction_info = Nokogiri::HTML(open(@selected_attraction_url))
node = attraction_info.css('.reviewpads')
if node.empty?
attraction.rating=("N/A")
else
node1 = attraction_info.css('.reviewpads').attribute('class').value.split[1].split('star')
attraction.rating=(node1[0].capitalize + " Stars")
end
node2 = attraction_info.css('.about-attraction').children.css('p').text
if node2.empty?
attraction.description=("N/A")
else
attraction.description=(node2)
end
node3 = attraction_info.css('.daydetail')
if node3.nil?
attraction.current_crowd_rating=("N/A")
else
attraction.current_crowd_rating=(node3.first.text)
end
node4 = attraction_info.css('.fff-attractions').children.css('li').children.css('a')
node4.each do |node|
attraction.priority_attractions << node.text
end
if attraction.priority_attractions.empty?
attraction.priority_attractions=("N/A")
end
node5 = attraction_info.css('.calattraction').attribute('data-filter-ids').value
if node5.include?('None')
attraction.hours=("N/A")
elsif
node6 = attraction_info.css('calattraction .filterableitem').nil?
attraction.hours=("N/A")
elsif
node6 = attraction_info.css('.calattraction .filterableitem .caltime')[0].nil?
attraction.hours=("N/A")
else
node6 = attraction_info.css('.calattraction .filterableitem .caltime')[0].text.strip
if node6 == nil
attraction.hours=("N/A")
elsif node6.include?('EMH')
node7 = attraction_info.css('.calattraction .filterableitem .caltime')[1].text.strip
hours = "#{node6} " + "/ #{node7}"
attraction.hours=(hours)
else
hours = "#{node6}"
attraction.hours=(hours)
end
end
end
|