Skip to content

Instantly share code, notes, and snippets.

@mort
Created April 20, 2010 09:12
Show Gist options
  • Save mort/372223 to your computer and use it in GitHub Desktop.
Save mort/372223 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'httparty'
require 'nokogiri'
require 'open-uri'
class Twitter
include HTTParty
base_uri 'twitter.com'
def initialize(user, password)
@auth = {:username => user, :password => password}
end
def tweet(text)
options = { :query => {:status => text}, :basic_auth => @auth }
self.class.post('/statuses/update.json', options)
end
end
class Prolix
@@user = '*****'
@@password = '*****'
def self.run
doc = Nokogiri::HTML(open('http://prolix.dyndns.info'))
score = doc.css('p.prediccion strong').first.content
if score
@client = Twitter.new(@@user,@@password)
@client.tweet("La Agencia Española de Meteorología acierta el #{score} de las veces. Más información en http://prolix.dyndns.info #prolix #abredatos")
end
end
end
Prolix::run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment