Skip to content

Instantly share code, notes, and snippets.

@claymcleod
Last active March 11, 2019 22:25
Show Gist options
  • Save claymcleod/b3adc0a5ca47b716dd6b to your computer and use it in GitHub Desktop.
Save claymcleod/b3adc0a5ca47b716dd6b to your computer and use it in GitHub Desktop.
Simple ruby datamining example
# Title: Simple Ruby Datamining Example
# Authors: Clay McLeod
# Description: Mines data every minute concerning how many people are logged into a certain subreddit.
# Section: Ruby
# Subsection: Data Science
require 'csv'
require 'rubygems'
require 'nokogiri'
require 'rest-client'
while true
CSV.open("./data.csv", "ab") do |csv|
doc = Nokogiri::HTML(RestClient.get("http://www.reddit.com/r/destinythegame"))
text = doc.xpath('//html/body/div/div/div/p/span')[0].text
csv << [Time.now, text]
end
sleep 60
end
@pirj
Copy link

pirj commented Feb 23, 2015

This works, but is an example of how code was usually written in Pascal or bare C, not how it should be written in Ruby.

@claymcleod
Copy link
Author

What do you mean? @pirj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment