Merge pull request #282 from drevicko/cursor-pages
added option to cursor() to yeild "page" - ie: iterators over each page returned by twitter
This commit is contained in:
commit
10e60fca10
1 changed files with 6 additions and 3 deletions
|
|
@ -390,7 +390,7 @@ class Twython(EndpointsMixin, object):
|
|||
)
|
||||
return self.cursor(self.search, q=search_query, **params)
|
||||
|
||||
def cursor(self, function, **params):
|
||||
def cursor(self, function, return_pages=False, **params):
|
||||
"""Returns a generator for results that match a specified query.
|
||||
|
||||
:param function: Instance of a Twython function (Twython.get_home_timeline, Twython.search)
|
||||
|
|
@ -421,6 +421,9 @@ class Twython(EndpointsMixin, object):
|
|||
else:
|
||||
results = content
|
||||
|
||||
if return_pages:
|
||||
yield results
|
||||
else:
|
||||
for result in results:
|
||||
yield result
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue