python - Tweepy 库不显示数据
问题描述
在我的python
Flask
解决方案中,我tweepy
实现了一个模块,以便仅显示我帐户中的一些流行推文和推文。在从官方文档中成功实现代码后,我遇到了一个不时发生的奇怪错误——推文也没有显示在页面和终端中。你可以在下面看到我的代码。
auth = tweepy.OAuthHandler(
'myID', 'mySecret')
auth.set_access_token(
'myToken', 'myTokenSecret')
api = tweepy.API(auth)
api.secure = True
search = request.args.get('q')
public_tweets = api.user_timeline(search)
covid_tweets = api.search(q="Sombor Tweets")
for tweet in covid_tweets:
print(tweet.text.encode("utf-8"))
...
return render_template('home.html', tweets=public_tweets, sombortweets =covid_tweets)
{% for tweet in tweets %}
<div class="card mt-2">
<div class="card-body">
<div class="card-text">
{{ tweet._json.text }}
</div>
</div>
</div>
{% endfor %}
{% for tweet in sombortweets %}
<div class="card mt-2">
<div class="card-body">
<div class="card-text">
{{ tweet._json.text }}
</div>
</div>
</div>
{% endfor %}
我期待你的回答,我希望有人遇到同样的情况。问候。
解决方案
推荐阅读
- google-cloud-platform - 我可以为多区域 GKE 集群配置 Google 全局负载均衡器吗
- linux - UBoot 中的错误“将环境保存到 MMC...写入 MMC(0)...失败失败 (1)”
- nightwatch.js - Nightwatch.JS Vercel 集成
- javascript - 使用 Jest/Enzyme 测试拖放事件监听器
- codenameone - Can an iOS native interface use NSData (byte[]) as a parameter or return value?
- google-sheets-api - 我的 Google Sheets API 控制台有重复的窗格
- sql - Postgresql 12 触发器更新与动态 SQL EXECUTE
- node.js - Meteor.loginWithPassword 不适用于带有 @ 字符的用户名
- sed - 使用前一行的缩进添加新行
- node.js - 是什么导致 XML 中的命名空间前缀与服务器不同