Skip to content

Instantly share code, notes, and snippets.

@nefo-mi
Created October 24, 2012 14:33
Show Gist options
  • Save nefo-mi/3946411 to your computer and use it in GitHub Desktop.
Save nefo-mi/3946411 to your computer and use it in GitHub Desktop.
userstreamからurlが含まれるツイートだけ収集する
#!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
require 'user_stream'
require 'yaml'
require 'uri'
config_path = File.expand_path(File.dirname(__FILE__) + '/config.yml')
stream_config = YAML.load_file(config_path)
UserStream.configure do |config|
config.consumer_key = stream_config[:consumer_key]
config.consumer_secret = stream_config[:consumer_secret]
config.oauth_token = stream_config[:oauth_token]
config.oauth_token_secret = stream_config[:oauth_token_secret]
end
client = UserStream.client
client.user do |status|
if status.has_key? "text"
if status.text =~ URI.regexp
puts status.text
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment