DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Emad has posted 58 posts at DZone. View Full User Profile

Printing twitter and github followers

  • submit to reddit
#!/usr/bin/env ruby
# Author : Emad Elsaid (
# 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("{username}").read
  followers = page.scan(/<.+>([0-9]+)<.+>[[:space:]]+followers/i).flatten.first
  puts "Github : #{followers} Followers"

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

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