如何获取整个推文而不是带有链接的推文的一部分 [英] how to get the whole tweet instead of a part of tweet with links

查看:52
本文介绍了如何获取整个推文而不是带有链接的推文的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Twython 库来获取推文.但大多数推文并不完整,并以一个简短的 URL 结尾,其中包含整个推文.有什么办法能让我度过难关.这是示例代码:

I am using Twython library for tweets acquisition. but most of the tweets are not complete and end with a short URL where the whole tweet is present. Is there any way that I can get through it. here is the sample code:

results=twitter.search(q="python")
all_tweets=results['statuses']
for tweet in all_tweets:
    print(tweet['text'])

推荐答案

要查看扩展的推文,您只需将此参数提供给您的搜索查询:tweet_mode=extended.

In order to see the extended tweet you just need to supply this parameter to your search query: tweet_mode=extended.

然后,您将在返回推文的 full_text 字段中找到扩展推文.我不使用 Python,但根据文档,我认为您应该执行以下操作:

Then, you will find the extended tweet in the full_text field of the returned tweet. I don't work in Python, but based on the documentation I think you should do something like:

results = twitter.search(q='pizza', tweet_mode='extended')
for result in results['statuses']:
    print(result['full_text'])

这篇关于如何获取整个推文而不是带有链接的推文的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆