pjb3 (owner)

Revisions

  • e24db4 Thu May 07 05:21:56 -0700 2009
gist: 108071 Download_button fork
public
Public Clone URL: git://gist.github.com/108071.git
Embed All Files: show embed
apressdotd.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/local/bin/ruby
require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'twitter'
 
url = "http://apress.com/info/dailydeal"
max_book_title_length = 140 - url.length - 8
if book = Hpricot(open(url)).at('.bookdetails h3 a').inner_html
  httpauth = Twitter::HTTPAuth.new('apressdotd', 'too_many_secrets')
  base = Twitter::Base.new(httpauth)
  base.update("#{book.slice(0..max_book_title_length)} #{url}")
end