Twitter
This is the general entrypoint for any application, constructed with Twitter()
- class tweety.bot.Twitter(max_retries: int = 10, proxy: dict | Proxy | None = None)
- __weakref__
list of weak references to the object (if defined)
- get_trends()
Get the Trends from you locale
:return:list of .types.twDataTypes.Trends
- get_tweets(username: str | int | User, pages: int = 1, replies: bool = False, retweets: bool = False, wait_time: int = 2, cursor: str | None = None)
Get the tweets from a user
- Param:
username: (
str
|int
|User
) username of the user whom to get the tweets of- Param:
pages: (
int
) number of pages to be scraped- Param:
replies: (
boolean
) get the replied tweets of the user too- Param:
retweets: (
boolean
) get the retweets of the user too- Param:
wait_time: (
int
) seconds to wait between multiple requests- Param:
cursor: Pagination cursor if you want to get the pages from that cursor up-to (This cursor is different from actual API cursor)
- Returns:
.types.usertweet.UserTweets
- get_user_info(username: str, banner_extensions: bool = False, image_extensions: bool = False)
Get the User Info of the specified username
- Parameters:
username – (
str
) username to get information ofbanner_extensions – (
boolean
) Get the Banner extension on the user pageimage_extensions – (
boolean
) Get the Image extension on the user page
- Returns:
.types.twDataTypes.User
- iter_search(query: str, search_filter: Literal['live', 'users', 'photos', 'videos'] = 'live', pages: int = 1, wait_time: int = 2, cursor: str | None = None)
Search for a keyword or hashtag on Twitter
- Parameters:
:param wait_time : (
int
) seconds to wait between multiple requests :param cursor: (str
) Pagination cursor if you want to get the pages from that cursor up-to (This cursor is different from actual API cursor)- Returns:
list[.types.twDataTypes.Tweet]
- iter_tweets(username: str | int | User, pages: int = 1, replies: bool = False, retweets: bool = False, wait_time: int = 2, cursor: str | None = None)
Generator for getting the tweets from a user
- Param:
username: (
str
|int
|User
) username of the user whom to get the tweets of- Param:
pages: (
int
) number of pages to be scraped- Param:
replies: (
boolean
) get the replied tweets of the user too- Param:
wait_time: (
int
) seconds to wait between multiple requests- Param:
cursor: Pagination cursor if you want to get the pages from that cursor up-to (This cursor is different from actual API cursor)
- Returns:
(.types.usertweet.UserTweets, list[.types.twDataTypes.Tweet])
- search(query: str, search_filter: Literal['live', 'users', 'photos', 'videos'] = 'live', pages: int = 1, wait_time: int = 2, cursor: str | None = None)
Search for a keyword or hashtag on Twitter
- Parameters:
:param wait_time : (
int
) seconds to wait between multiple requests :param cursor: (str
) Pagination cursor if you want to get the pages from that cursor up-to (This cursor is different from actual API cursor)- Returns:
(.types.searchtweet.SearchTweet, list[.types.twDataTypes.Tweet])