如何在Twitter搜索API中获取全文?

2024-10-04 03:15:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用了twitter搜索API,还合并了extended_modefull_text属性,但是我仍然从API中得到一个截断的字符串

这是我的密码:

results = t.search(q='tuberculosis', count=50, lang='en', result_type='popular',tweet_mode='extended')
all_tweets = results['statuses']

for tweet in all_tweets:
        tweetString = tweet["full_text"]
        userMentionList = tweet["entities"]["user_mentions"]
        if len(userMentionList)>0:
            for eachUserMention in userMentionList:
                name = eachUserMention["screen_name"]
                time = tweet["created_at"]
                wks.insert_rows(wks.rows, values=[tweetString, name, time], inherit=True)
    

Tags: textnameinapiextendedformodeall
1条回答
网友
1楼 · 发布于 2024-10-04 03:15:38

如果您使用的是TwitterSearch,以下功能应该可以正常工作:

tso = TwitterSearchOrder()
tso.set_keywords('tuberculosis')
for tweet in ts.search_tweets_iterable(tso):
    print(tweet['text'])

当然,您可以设置所需的属性,如语言和计数

相关问题 更多 >