Ed Bockelman

Using Python to speed up finding friends on Twitter

I'm taking a course from Kevon at PublicLab about using Twitter and Build in Public principles to grow an audience and build a product for them at the same time.

What I'm learning is super useful.  You can find a sample here.  It's Kevon's free 7-day email course.  I won't go into that in-depth here because you can learn the basic principles there.  

I'm going to briefly cover how I'm using Python and the Twitter API to speed up the process of finding friends on Twitter.

What my scripts do

First, find influencers in the target space.  I won't cover that here.  But say you know five or six (or twenty) influencers in your target audience.  They are probably people you follow and look up to, and you want to build an audience like theirs.

Create a text file with the Twitter handles, one per line.  I'm using influencers in the Chinese language learning community as examples since that's my current project.



Next, start the script.  It will grab the followers of each influencer and save them to a document (currently using a .csv file).  It only saves followers who follow at least two influencers (so we know the person is serious about the subject).

I'm using Twitter's free API so it has rate limits.  I set a delay of 5 minutes between influencers.  It takes a long time, so let it run while you are doing something else (sleeping, for example).

Once the script is done, it creates a spreadsheet I can sort to look for people to follow.  I can sort them by who they follow, by how many followers they have, etc.  It also includes their bio and the name of the person their last tweet was written to (or None, if that's the case).  

I sort the table by the criteria I want (more about that in the future if you are interested).  The last field in each row is HTML code.  I take that section and copy and paste it into a blank HTML document.  Then I can use that to help me quickly click on the Twitter handles of users that look promising, to learn more about them.

That's it for now.  I'll update this post with more info depending on the interest I receive.