Skip to content

Instantly share code, notes, and snippets.

@eric
Created August 8, 2008 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eric/4629 to your computer and use it in GitHub Desktop.
Save eric/4629 to your computer and use it in GitHub Desktop.
Making it simple to provide input for http://wordle.net/create
#
# Created by Eric Lindvall <eric@5stops.com>
#
# Making it simple to provide input for http://wordle.net/create
#
#
require 'rubygems'
gem 'mechanize'
require 'mechanize'
def collect_entries(page)
page.parser.search('.entry-content').collect do |span|
span.search('a').remove
span.inner_text.strip.gsub(/(^|\s+)@($|\W+)/, '')
end
end
def gather_all_tweets(username, password)
agent = WWW::Mechanize.new
agent.user_agent_alias = 'Mac Safari'
page = agent.get('http://twitter.com/account/archive')
login_form = page.forms.action('https://twitter.com/sessions').first
login_form['username_or_email'] = username
login_form['password'] = password
login_form.submit
page = agent.get('http://twitter.com/account/archive')
unless page.forms.action('https://twitter.com/sessions').first.nil?
raise "The username or password was invalid"
end
text = collect_entries(page)
while link = page.links.text(/Older/).first
page = link.click
text += collect_entries(page)
end
text.flatten
end
username, password = ARGV[0], ARGV[1]
puts gather_all_tweets(username, password).join("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment