Class: Landmarks::Scraper
- Inherits:
-
Object
- Object
- Landmarks::Scraper
- Defined in:
- lib/landmarks/scraper.rb
Instance Method Summary collapse
- #get_landmark_page(url) ⇒ Object
- #get_page ⇒ Object
-
#print_landmarks_urls ⇒ Object
def print_landmarks_index Landmarks::Landmark.all.each.with_index do |el, index| puts “#index+1.t#elel.name” end nil end.
- #print_the_title ⇒ Object
- #scrape_landmark_description(url) ⇒ Object
- #scrape_landmark_directions(url) ⇒ Object
- #scrape_landmark_name(url) ⇒ Object
- #scrape_landmarks_index ⇒ Object
Instance Method Details
#get_landmark_page(url) ⇒ Object
35 36 37 |
# File 'lib/landmarks/scraper.rb', line 35 def get_landmark_page(url) Nokogiri::HTML(open(url)) end |
#get_page ⇒ Object
7 8 9 |
# File 'lib/landmarks/scraper.rb', line 7 def get_page Nokogiri::HTML(open("http://www.saint-petersburg.com/top-20-attractions/")) end |
#print_landmarks_urls ⇒ Object
29 30 31 32 |
# File 'lib/landmarks/scraper.rb', line 29 def print_landmarks_urls Landmarks::Landmark.all.each.with_index { |el, index| puts "#{index+1}.\t#{el.url}" } nil end |
#print_the_title ⇒ Object
18 19 20 |
# File 'lib/landmarks/scraper.rb', line 18 def print_the_title puts self.get_page.css("h1").text end |
#scrape_landmark_description(url) ⇒ Object
43 44 45 |
# File 'lib/landmarks/scraper.rb', line 43 def scrape_landmark_description(url) self.get_landmark_page(url).css("p").text end |
#scrape_landmark_directions(url) ⇒ Object
47 48 49 |
# File 'lib/landmarks/scraper.rb', line 47 def scrape_landmark_directions(url) self.get_landmark_page(url).css(".prop-list").text end |
#scrape_landmark_name(url) ⇒ Object
39 40 41 |
# File 'lib/landmarks/scraper.rb', line 39 def scrape_landmark_name(url) self.get_landmark_page(url).css("h1").text end |