Class: ConfedScraper::ConfreaksScraper
- Defined in:
- lib/confed_scraper/confreaks_scraper.rb
Constant Summary collapse
- SITE_URI =
"http://confreaks.net"
Instance Attribute Summary
Attributes inherited from Scraper
Instance Method Summary collapse
Methods inherited from Scraper
#get_content_from, #initialize, #scrape_message
Constructor Details
This class inherits a constructor from ConfedScraper::Scraper
Instance Method Details
#process ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/confed_scraper/confreaks_scraper.rb', line 5 def process content = get_content_from(url) videos_doc= Nokogiri::HTML.parse(content) links = videos_doc.xpath('//*[@class="video"]//*[@class="title"]/a') video_data = [] links.each_with_index do |link| vid = {} show_page_url = SITE_URI + link.attr('href') show_page_content = RestClient.get(show_page_url) show_page_doc = Nokogiri::HTML.parse(show_page_content) (show_page_url) title = show_page_doc.xpath('//*[@class="video-title"]').text.strip vid[:title] = title vid[:uri] = show_page_url vid[:presenters] = show_page_doc.xpath('//*[@class="video-presenters"]/a').map(&:text) vid[:description] = show_page_doc.xpath('//*[@class="video-abstract"]/p').text.strip video_data << vid end video_data end |