Twitter: Difference between revisions

952 bytes added ,  11 years ago
imported>Jesstess
imported>Jesstess
Line 54:
# Read through the <code>trendingTopics</code> function in <code>twitter_functions.py</code>.
# Trace through the logic in <code>twitter_api.py</code> that turns the <code>--trending-topics</code> command line option into a call to <code>search</code>.
# Find <code>GetTrendsWoeid</code> in the Twitter library code at http://code.google.com/p/python-twitter/source/browse/twitter.py. How many trending topics does that method return?
 
<b>Check your understanding</b>: What are the differences between the <code>optparse</code> logic for <code>--search</code> and <code>--trending-topics</code>?
Line 83 ⟶ 84:
=== 4. Implement <code>trendingTweets</code> ===
 
<ol>
# <li>Using the <code>search</code> and <code>trendingTopics</code> functions as a reference, implement <code>trendingTweets</code> in <code>twitter_functions.py</code>.
 
This function should print a couple of recent tweets from each of the currently trending topics.
 
<li>We've already written some <code>optparse</code> logic for <code>userTweets</code> in <code>twitter_api.py</code>. Read through that logic. In what ways is it the same/different from the logic for <code>search</code>?
<li>Test your function. You can do this with:
 
<pre>python twitter_api.py -w</pre>
</li>
 
You should see recent tweets from all of the currently trending topics. Depending on how you implemented your function, you might see a chunk of tweets from each trending topic in turn, or tweets from each topic interleaved.
</ol>
 
<b>Check your understanding</b>: What is the purpose of <code>BOSTON_WOEID</code> in <code>twitter_functions.py</code>?
 
 
Anonymous user