小编Mar*_*ano的帖子

Twitter API 搜索返回截断的推文

我正在尝试构建一个 python 程序来获取基于某个关键字的推文。然而,虽然我可以成功检索推文,但它们会被截断。

如何获取推文的全文?

代码:(代码下方的示例输出)(python-twitter 模块)

import twitter

api = twitter.Api(consumer_key=CONSUMER_KEY,
                  consumer_secret=CONSUMER_SECRET,
                  access_token_key=ACCESS_TOKEN,
                  access_token_secret=ACCESS_SECRET)
results = api.GetSearch(term="car", since="2018-04-11", until="2018-04-12", count=5)

for twt in results:
    tempTweet = (str(twt))
tweet = json.loads(tempTweet)
for key in tweet:
    print(str(key) + ": " + str(tweet[key]))

print("#############################################")
Run Code Online (Sandbox Code Playgroud)

样品输出:

created_at: Wed Apr 11 20:55:25 +0000 2018
favorite_count: 1573
hashtags: []
id: 984173096566341632
id_str: 984173096566341632
lang: en
retweet_count: 1480
source: <a href="https://about.twitter.com/products/tweetdeck" rel="nofollow">TweetDeck</a>
**text**: Caution: Disturbing video. Car speeds through red light, striking pedestrian during vigil Wednesday for …
Run Code Online (Sandbox Code Playgroud)

python twitter python-twitter

1
推荐指数
1
解决办法
2439
查看次数

标签 统计

python ×1

python-twitter ×1

twitter ×1