Commit 79bf5571 authored by Aaron Hill's avatar Aaron Hill
Browse files

Use tweepy.Cursor instead of Cursor in cursor tutorial

parent a1b8ea04
...@@ -39,7 +39,7 @@ As you can see we must manage the "page" parameter manually in our ...@@ -39,7 +39,7 @@ As you can see we must manage the "page" parameter manually in our
pagination loop. Now here is the version of the code using Cursor pagination loop. Now here is the version of the code using Cursor
object:: object::
for status in Cursor(api.user_timeline).items(): for status in tweepy.Cursor(api.user_timeline).items():
# process status here # process status here
process_status(status) process_status(status)
...@@ -60,7 +60,7 @@ Since we pass Cursor the callable, we can not pass the parameters ...@@ -60,7 +60,7 @@ Since we pass Cursor the callable, we can not pass the parameters
directly into the method. Instead we pass the parameters into the directly into the method. Instead we pass the parameters into the
Cursor constructor method:: Cursor constructor method::
Cursor(api.user_timeline, id="twitter") tweepy.Cursor(api.user_timeline, id="twitter")
Now Cursor will pass the parameter into the method for us when ever it Now Cursor will pass the parameter into the method for us when ever it
makes a request. makes a request.
...@@ -72,7 +72,7 @@ So far we have just demonstrated pagination iterating per an ...@@ -72,7 +72,7 @@ So far we have just demonstrated pagination iterating per an
item. What if instead you want to process per a page of results? You item. What if instead you want to process per a page of results? You
would use the pages() method:: would use the pages() method::
for page in Cursor(api.user_timeline).pages(): for page in tweepy.Cursor(api.user_timeline).pages():
# page is a list of statuses # page is a list of statuses
process_page(page) process_page(page)
...@@ -85,9 +85,9 @@ What if you only want n items or pages returned? You pass into the items() or pa ...@@ -85,9 +85,9 @@ What if you only want n items or pages returned? You pass into the items() or pa
.. code-block :: python .. code-block :: python
# Only iterate through the first 200 statuses # Only iterate through the first 200 statuses
for status in Cursor(api.user_timeline).items(200): for status in tweepy.Cursor(api.user_timeline).items(200):
process_status(status) process_status(status)
# Only iterate through the first 3 pages # Only iterate through the first 3 pages
for page in Cursor(api.user_timeline).pages(3): for page in tweepy.Cursor(api.user_timeline).pages(3):
process_page(page) process_page(page)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment