tweepy
v4.12.0
  • Instalacja
  • Pierwsze kroki
  • Authentication
  • Logging
  • Przesyłanie strumieniowe

Twitter API v1.1 Reference

  • API
  • Stream
  • AsyncStream
  • Wyjątki
  • Models
  • Pagination
  • Rozszerzone Tweety

Twitter API v2 Reference

  • Client
  • Response
  • StreamingClient
  • StreamResponse
  • StreamRule
  • AsyncClient
  • AsyncStreamingClient
  • Wyjątki
  • Expansions and Fields
  • Models
  • Pagination

Meta

  • Changelog
  • Development
  • Examples
  • Frequently Asked Questions
tweepy
  • »
  • Pagination
  • Edytuj na GitHub

Pagination

class tweepy.Cursor(method, *args, **kwargs)

Cursor can be used to paginate for any API methods that support pagination

Parametry
  • method – API method to paginate for

  • args – Positional arguments to pass to method

  • kwargs – Keyword arguments to pass to method

items(limit=inf)

Retrieve the items in each page/request

Parametry

limit – Maximum number of items to iterate over

Zwraca

Iterator to iterate through items

Typ zwracany

ItemIterator

pages(limit=inf)

Retrieve the page for each request

Parametry

limit – Maximum number of pages to iterate over

Zwraca

Iterator to iterate through pages

Typ zwracany

CursorIterator or DMCursorIterator or IdIterator or NextIterator or PageIterator

Example

import tweepy

auth = tweepy.OAuth2AppHandler("Consumer Key here", "Consumer Secret here")
api = tweepy.API(auth)

for status in tweepy.Cursor(api.search_tweets, "Tweepy",
                            count=100).items(250):
    print(status.id)

for page in tweepy.Cursor(api.get_followers, screen_name="TwitterDev",
                            count=200).pages(5):
    print(len(page))
Poprzedni Następny

© Copyright 2009-2022, Joshua Roesslein. Revision a07d225f.

Zbudowano w Sphinx używając theme dostarczone przez Read the Docs.