Skip to content

Instantly share code, notes, and snippets.

Last active Apr 12, 2019
What would you like to do?
Twitter bio search

A friend is looking for a new tech job and asked if I knew anyone at a handful of companies. I'm (meaningfully) connected to more people who are relevant to this on Twitter than LinkedIn, so figured it would be easiest to scour people's bios. Naturally, I did this in the nerdiest way possible and automated it.

<3 @aidanfeldman

P.S. See also:

# usage:
# $ gem install t twitter
# $ t authorize
# $ ruby twitter_bio_search.rb
# from XXX peeps:
# name - @screen_name - bio
# ...
require 'yaml'
require 'twitter'
# created via 't' gem CLI
# just grab first authentication
AUTH_INFO = YAML.load_file('/Users/afeld/.trc')['profiles'].values[0].values[0]
client = do |config|
config.consumer_key = AUTH_INFO['consumer_key']
config.consumer_secret = AUTH_INFO['consumer_secret']
config.access_token = AUTH_INFO['token']
config.access_token_secret = AUTH_INFO['secret']
# gather followers + following
all_ids =
client.follower_ids.each do |follower_id|
all_ids << follower_id
client.friend_ids.each do |following_id|
all_ids << following_id
puts "from #{all_ids.size} peeps:\n\n"
TERM_REGEX = /birchbox|bonobos|codecademy|etsy|foursquare|gilt|google|levo|okcupid|seamless|spotify|squarespace|streeteasy|tumblr|vimeo|warby/i
users_by_terms = {}
# can only retrieve 100 at a time
all_ids.each_slice(100) do |some_ids|
client.users(*some_ids, include_entities: false).each do |user|
desc = user.description
if desc
desc.scan(TERM_REGEX) do |term|
term = term.downcase
users_by_terms[term] ||=
users_by_terms[term] << user
users_by_terms.sort.each do |term, users|
puts term.upcase
users.each do |user|
desc = user.description
if desc
# compress whitespace
desc = desc.gsub(/\s+/, ' ')
puts "{user.screen_name} – #{}#{desc}"
puts "\n"
Copy link

orta commented May 17, 2013

This is cool. You can have a 👍

Copy link

melodykramer commented Jul 12, 2016

was searching for how to do this. Of course it's from you.

Copy link

almereyda commented Jul 31, 2016

I have created a fork at which also searches the location field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment