[PR]
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
- async flatten(limit=inf)
Flatten paginated data
- パラメータ:
limit -- Maximum number of results to yield