Skip to content

Instantly share code, notes, and snippets.

@kendaganio
Created February 5, 2013 13:24
Show Gist options
  • Save kendaganio/4714431 to your computer and use it in GitHub Desktop.
Save kendaganio/4714431 to your computer and use it in GitHub Desktop.
How awesome is bayantel
require 'net/http'
require 'uri'
require 'json'
total = 100
uri = URI.parse("http://search.twitter.com/search.json?q=bayantel&rpp=#{total}&include_entities=true&result_type=mixed");
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri);
response = http.request(request)
json = JSON.parse(response.body)
statuses = json['results']
good = 0
bad = 0
statuses.each do |s|
text = s['text'].downcase
if text[/(bagal)|(slow)|(hina)|([f|s]uck)|(pang[e|i]t)/]
bad += 1
end
if text[/(bilis)|(fast)|(lakas)|(ganda)|(awesome)/]
good += 1
end
end
puts "Good: #{good}, Bad: #{bad}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment