Skip to content

Instantly share code, notes, and snippets.

@oddlyfunctional
Created August 12, 2015 14:42
Show Gist options
  • Save oddlyfunctional/8085ec0b6dba8d0d9199 to your computer and use it in GitHub Desktop.
Save oddlyfunctional/8085ec0b6dba8d0d9199 to your computer and use it in GitHub Desktop.
require 'nokogiri'
require 'open-uri'
require 'elasticsearch'
college_doc = Nokogiri::HTML(open('http://www.example-college.com'))
college_course = college_doc.at_css('.course')
course_hash = {
title: college_course.at_css('h1').text,
start_date: college_course.at_css('.start-date').text
}
ranking_doc = Nokogiri::HTML(open('http://www.ranking-college.com'))
ranking_course = ranking_doc.at_css('.course')
course_hash[:ranking] = ranking_course.at_css('.ranking').text
client = Elasticsearch::Client.new
client.index index: 'courses', type: 'course', id: course_hash[:title], body: course_hash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment