Created
October 26, 2011 13:58
-
-
Save jellybob/1316433 to your computer and use it in GitHub Desktop.
Win "be the nth follower" contests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'capybara' | |
require 'capybara/dsl' | |
require 'capybara/webkit' | |
include Capybara::DSL | |
account = ARGV[0] | |
count = ARGV[1] | |
Capybara.current_driver = :webkit | |
Capybara.app_host = 'http://mobile.twitter.com' | |
visit "/#{account}" | |
followers = page.find(%Q{a[href="http://mobile.twitter.com/#{account.downcase}/followers"]}).text.split(':').last.to_i | |
while true | |
if followers == count - 1 | |
%x{say 'Follow #{account} now to win.'} | |
else | |
puts "Checked, #{followers} followers. Sleeping for 15 seconds." | |
sleep 15 | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem install capybara capybara-webkit | |
ruby follower_count.rb AccountWithFreeStuff 1000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment