Twython Twitter帖子被截断了

问题描述 投票:0回答:1

我正在尝试使用Twython获得一些推文,但即使使用tweet_mode:extended,结果仍然会被截断。关于如何获取全文的任何想法。

def requestTweets(topic, resultType = "new", amount = 10, language = "en"):
'''Get the n tweets for a topic, either newest (new) or most popular (popular)'''
#Create Query
query = {'q': topic,
        'result_type': resultType,
        'count': amount,
        'lang': language,
        'tweet_mode': 'extended',
        }

#Get Data
dict_ = {'user': [], 'date': [], 'full_text': [],'favorite_count': []}
for status in python_tweets.search(**query)['statuses']:
    dict_['user'].append(status['user']['screen_name'])
    dict_['date'].append(status['created_at'])
    dict_['full_text'].append(status['full_text'])
    dict_['favorite_count'].append(status['favorite_count'])

# Structure data in a pandas DataFrame for easier manipulation
df = pd.DataFrame(dict_)
df.sort_values(by='favorite_count', inplace=True, ascending=False)
return df

tweets = requestTweets("chocolate")
for index, tweet in tweets.iterrows():
    print("***********************************")
    print(tweet['full_text'])

结果看起来像这样:

enter image description here

python twitter twython twitterapi-python
1个回答
-1
投票

我使用twitterscraper https://pypi.org/project/twitterscraper/0.2.7/,我知道它可以为我提供完整的推文输出。希望对您有所帮助。您也可以从cmdline运行它。

这仅对公开推文有用。

这里是“巧克力”的一些样品结果

[{“ has_media”:false,“ hashtags”:[],“ img_urls”:[],“ is_replied”:false,“ is_reply_to”:false,“点赞”:0,“链接”:[],“ parent_tweet_id“:”“,” replies“:0,” reply_to_users“:[],” retweets“:0,” screen_name“:” MellenniumBeats“,” text“:” Aaaahh !!刚洗完澡,闻起来像黑漆“ Chocolate Temptations。”,“ text_html”:“ Aaaahh !!刚从淋浴中出来,闻起来像黑的chocolate Temptations。

”,“ timestamp”:“ 2009-09-26T23:59:53”,“ timestamp_epochs”:1254009593,“ tweet_id”:“ 4405140852”,“ tweet_url”:“ / MellenniumBeats / status / 4405140852”,“ user_id”:“ 32231346”,“用户名”:“ Mellennium。”,“ video_url”:“”} ,

{“ has_media”:否,“ hashtags”:[],“ img_urls”:[],“ is_replied”:否,“ is_reply_to”:否,“ likes”:0,“链接”:[],“ parent_tweet_id “:”,“ replies”:0,“ reply_to_users”:[],“ retweets”:0,“ screen_name”:“ leticiagdo”,“ text”:“ Cansada!Aula o dia inteiro hoje ...完美的巧克力软糖蛋糕”,“ text_html”:“ Cansada!Aula o dia inteiro hoje ...甜甜圈的巧克力软糖[[chocolate完美的巧克力咖啡粉

”,“时间戳“:”“ 2009-09-26T23:59:47”,“ timestamp_epochs”:1254009587,“ tweet_id”:“ 4405139277”,“ tweet_url”:“ / leticiagdo / status / 4405139277”,“ user_id”:“ 61966870”,“用户名”:“ Let \ u00edcia Oliveira”,“ video_url”:“”},...
© www.soinside.com 2019 - 2024. All rights reserved.