Pagination
- class tweepy.Paginator(self, method, *args, limit=inf, pagination_token=None, **kwargs)
Paginatorcan be used to paginate for anyClientmethods that support pagination참고
When the returned response from the method being passed is of type
requests.Response, it will be deserialized in order to parse the pagination tokens, likely negating any potential performance benefits from using arequests.Responsereturn type.버전 4.0에 추가.
- 매개변수
method –
Clientmethod to paginate forargs – Positional arguments to pass to
methodlimit – Maximum number of requests to make to the API
pagination_token – Pagination token to start pagination with
kwargs – Keyword arguments to pass to
method
- flatten(limit=inf)
Flatten paginated data
- 매개변수
limit – Maximum number of results to yield
Example
import tweepy
client = tweepy.Client("Bearer Token here")
for response in tweepy.Paginator(client.get_users_followers, 2244994945,
max_results=1000, limit=5):
print(response.meta)
for tweet in tweepy.Paginator(client.search_recent_tweets, "Tweepy",
max_results=100).flatten(limit=250):
print(tweet.id)
- class tweepy.asynchronous.AsyncPaginator(self, method, *args, limit=inf, pagination_token=None, **kwargs)
AsyncPaginatorcan be used to paginate for anyAsyncClientmethods that support pagination참고
When the returned response from the method being passed is of type
aiohttp.ClientResponse, it will be deserialized in order to parse the pagination tokens, likely negating any potential performance benefits from using aaiohttp.ClientResponsereturn type.버전 4.11에 추가.
- 매개변수
method –
AsyncClientmethod to paginate forargs – Positional arguments to pass to
methodlimit – Maximum number of requests to make to the API
pagination_token – Pagination token to start pagination with
kwargs – Keyword arguments to pass to
method
- flatten(limit=inf)
Flatten paginated data
- 매개변수
limit – Maximum number of results to yield