Skip to content

Instantly share code, notes, and snippets.

@OdNairy
Last active December 15, 2015 18:38
Show Gist options
  • Save OdNairy/5304892 to your computer and use it in GitHub Desktop.
Save OdNairy/5304892 to your computer and use it in GitHub Desktop.
Ruby-скрипт для фоловинга 40404-ым =)
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'twitter'
require File.join(File.dirname(__FILE__), 'apn.rb')
Twitter.configure do |config|
config.consumer_key = '******************'
config.consumer_secret = '************************************************'
config.oauth_token = '************************************************'
config.oauth_token_secret = '************************************************'
end
@NEED = 40404
#@NEED = 40180
puts Twitter.unfollow("habrahabr")
while true
#doc = Nokogiri::HTML(open('https://twitter.com/habrahabr'))
#followers = doc.xpath("//div[@class='default-footer']//li[3]//a").inner_text.strip!.gsub!(",",'')[0..4].to_i
begin
followers = Twitter.user('habrahabr')['followers_count']
puts "#{followers}/#{@NEED}"
if followers > (@NEED-2)
Twitter.follow('habrahabr')
puts Time.now
puts "Started following habrahabr"
Apn.send("habrahabr is following now!",nil)
break
end
if followers < (@NEED - 30)
sleep(5)
else
sleep(1)
end
rescue Exception => e
puts e.message
Apn.send("Something crashed",nil)
puts 'something crashed!'
sleep(10)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment