back to top

Getting Twitter Handle Information

Without copying and pasting (pssst! You can get them from the API).

Posted on

Moar Trump Tweets!

After our project digging into Trump’s information universe, Charlie Warzel and I decided to take a quick gander at all the Twitter users Trump has retweeted since he launched his presidential campaign in June of 2015.

I updated the data analysis we did for our first story. We isolated all of the twitter.com links he posted that were retweets (retweets show up as links from twitter.com when downloaded as data) and then set out to find the biographies of every Twitter handle that was represented there. You can find that story here.

If you want to feed a list of twitter handles to a script and get back a rundown of what Twitter knows about each of those users, you can do that:

1. Start by getting developer oauth credentials from Twitter: https://apps.twitter.com/
2. If you don’t already have Python installed, start by getting Python up and running. Also, if you don’t already have a favorite package manager, you should also make sure you have pip.
3. Install tweepy: pip install tweepy
4. Copy twitter_bio_info_compiler.py to wherever you keep your scripts. Edit it to include your developer oauth credentials at the top and add a list of handles you want to scrape.
5. Run it with run python scrapername.py to generate a csv of bio information

This is the date structure of the csv:

name: the Twitter handle.
display_name: the display name of the Twitter handle.
bio: the biography of the Twitter handle.
followers_count: how many Twitter followers the handle has.
following_count: how many other users the Twitter handle follows
acct_created: the date the account was created
location: the location on the bio page of the Twitter handle

Enjoy!

Send thoughts to lam.vo@buzzfeed.com

Every. Tasty. Video. EVER. The new Tasty app is here!

Dismiss