Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

What's in a Tweet?


Published on

A very basic presentation on using Python to access the Twitter API and search public stings for a text string.

Published in: Technology
  • Login to see the comments

  • Be the first to like this

What's in a Tweet?

  1. 1. What's in a Tweet?
  2. 2. The Goal: <ul><li>Search the most recent public tweets of any user for a specific text string. </li></ul><ul><li>  </li></ul><ul><li>Using myself as an example, let's search for the string ' FCPX' , as I'm a video editor and tweeted a lot about that recently. </li></ul>
  3. 3. Finding a Python wrapper for the Twitter API Twython is pretty cool. It's as easy as this: Start up Terminal and type easy_install twython.  Done.
  4. 4. Variable Setup
  5. 5. What Twitter Actually Returns to You <ul><li>So you've set up user_timeline. And what is that exactly? </li></ul>Output:
  6. 6. Let's print user_timeline. <ul><li>Just because we want to see what it looks like. </li></ul>
  7. 8. OMG What Was That
  8. 9. No, it's not wrong. <ul><li>It's JSON data.  </li></ul><ul><li>  </li></ul><ul><li>Every tweet has much more information associated with it than just the raw text you see online.  </li></ul><ul><li>It looks intimidating, but it's not. JSON is just a bunch of nested dictionaries.  </li></ul><ul><li>  </li></ul><ul><li>You can easily parse JSON with basic Python dictionary methods.  </li></ul>
  9. 10. I found a JSON formatter to be useful. <ul><li> </li></ul>
  10. 11. Basic Python Dictionary Methods:
  11. 12. And Here's How the Goal is Achieved: <ul><li>FOR loop: </li></ul>With an IF loop: And some output:
  12. 13. Results!