提取完整的推特Tweepy Python



我找不到获取推文全文的方法,我已经激活了所有内容,tweet_mode="扩展的";我打印了tweet.full_text,但它一直在修剪tweet,我直接看了tweet_json,它也在那里被修剪了,我不明白为什么

import tweepy
import configparser
from datetime import datetime
def apiTwitter(): #Para conectarse a twitter y scrapear con su api, devuelve objeto de tweepy cheto para scrapear twitter
# read credentials
config = configparser.ConfigParser()
config.read('credentialsTwitter.ini')
api_key = config['twitter']['api_key']
api_key_secret = config['twitter']['api_key_secret']
access_token = config['twitter']['access_token']
access_token_secret = config['twitter']['access_token_secret']
# authentication
auth = tweepy.OAuthHandler(api_key,api_key_secret)
auth.set_access_token(access_token,access_token_secret)
api=tweepy.API(auth)
return api

api=apiTwitter() #Con api ahora podemos scrapear todo twitter de forma sencilla
tweets = api.user_timeline(screen_name='kowaalski_',tweet_mode="extended", count=1)
tweet=tweets[0]
#print(tweet._json)
print(f'Tweet text: {tweet.full_text}')

这是因为第一条推文是转发,并且转发的full_text属性仍然可以被截断。您必须访问转发状态的full_text属性。

基本示例:

try:
print(tweet.retweeted_status.full_text)
except AttributeError:  # So this is not a Retweet
print(tweet.full_text)

最新更新