What's in a Tweet?

1,015 views

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
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,015
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

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>http://jsonformatter.curiousconcept.com/ </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!

×