Joined April 2014
·

Dan Reynolds

Burlington, Ontario
·
·
·

Posted to Printing twitter and github followers over 1 year ago

I like it! made it into a file and let the person specify whoever they want:

#!/usr/bin/env ruby
# Author : Emad Elsaid (https://github.com/blazeeboy)
# 
# this script will get your followers count
# across socsial media, i get the user profile
# page and use Regex to grab the followers number
require 'open-uri'

# Getting github followers
def github( username )
  page = open("https://github.com/#{username}").read
  followers = page.scan(/<.+>([0-9]+)<.+>[[:space:]]+followers/i).flatten.first
  puts "Github : #{followers} Followers"
end

# get twitter followers by twitter handle
def twitter( username )
  page = open("https://twitter.com/#{username}").read
  followers = page.scan(/followers<.+>[[:space:]]+<.+>([0-9]+)<.+>/i).flatten.first
  puts "Twitter : #{followers} Followers"
end

# use them to print your followers
# using github username and
# twitter handle

if ARGV.count == 2
  github ARGV.first
  twitter ARGV.last
elsif ARGV.include? "--help"
  puts "Usage: ruby filename github_handle twitter_handle"

else
  puts "unrecognized option, Try '--help' for more information."
end
Achievements
34 Karma
447 Total ProTip Views