📜  Python – Tweepy 中的状态对象

📅  最后修改于: 2022-05-13 01:54:41.902000             🧑  作者: Mango

Python – Tweepy 中的状态对象

Twitter是一个流行的社交网络,用户在其中分享称为推文的消息。 Twitter 允许我们使用 Twitter API 或Tweepy挖掘任何用户的数据。数据将是从用户那里提取的推文。首先要做的是从 twitter 开发人员那里轻松获得每个用户可用的消费者密钥、消费者密钥、访问密钥和访问密钥。这些密钥将帮助 API 进行身份验证。

地位

Tweepy 模块中的Status对象包含有关状态/推文的信息。

以下是 Status 对象中的属性列表:

示例:考虑以下状态:

使用get_status()方法获取状态。

# import the module
import tweepy
  
# assign the values accordingly
consumer_key = ""
consumer_secret = ""
access_token = ""
access_token_secret = ""
  
# authorization of consumer key and consumer secret
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
  
# set access to user's access key and access secret 
auth.set_access_token(access_token, access_token_secret)
  
# calling the api 
api = tweepy.API(auth)
  
# the ID of the status
id = 1268080321590935553
  
# fetching the status
status = api.get_status(id)
  
# printing the information
print("The status was created at : " + str(status.created_at))
print("The id is : " + str(status.id))
print("The id_str is : " + status.id_str)
print("The text is : " + status.text)
print("The entitities are : " + str(status.entities))
print("The source is : " + status.source)
print("The source_url is : " + status.source_url)
  
  
print("The in_reply_to_status_id is : " + str(status.in_reply_to_status_id))
print("The in_reply_to_status_id_str is : " + str(status.in_reply_to_status_id_str))
print("The in_reply_to_user_id is : " + str(status.in_reply_to_user_id))
print("The in_reply_to_user_id_str is : " + str(status.in_reply_to_user_id_str))
print("The in_reply_to_screen_name is : " + str(status.in_reply_to_screen_name))
  
  
print("The poster's screen name is : " + status.user.screen_name)
print("The geo is : " + str(status.geo))
print("The coordinates are : " + str(status.coordinates))
print("The place is : " + str(status.place))
print("The contributors are : " + str(status.contributors))
print("The is_quote_status is : " + str(status.is_quote_status))
print("The retweet_count is : " + str(status.retweet_count))
print("The favorite_count is : " + str(status.favorite_count))
  
print("Has the authenticated user favourited the status? : " + str(status.favorited))
print("Has the authenticated user retweeted the status? " + str(status.retweeted))
print("Is the status possibly_sensitive? : " + str(status.possibly_sensitive))
print("The lang is : " + status.lang)

输出 :