python - Tweepy 将搜索限制为单个用户
问题描述
我正在尝试使用 tweepy api 搜索用户自己的推文,并返回包含用户输入的任何关键字的推文。因此,如果用户输入“Blue”作为关键字,它将搜索所有用户的推文,并返回任何包含字符串“Blue”的推文。
到目前为止,这是我的代码,它可以运行,但它似乎可以无限运行各种随机推文。如何将搜索限制为单个用户?
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)
for status in tweepy.Cursor(api.search, q="Blue", rpp=100, show_user=True).items():
print status.text
解决方案
from:user
在查询中使用添加用户的 twitter 句柄:
for status in tweepy.Cursor(api.search, q="Blue from:blueperson", rpp=100, show_user=True).items():
print status.text
推荐阅读
- reactjs - 使用 Dex 进行调试转换类导致 Windows 崩溃
- r - 在函数中使用省略号使用 tidy 原则读取数据
- python - DoCplex 中的 Bass 模型:如何在约束中分配变量
- azure - 指向 Azure 负载均衡器公共 IP 的 Azure 前门后端池未解析
- node.js - React-Admin:`make` 命令失败
- javascript - JavaScript - 我怎样才能让它更动态?
- javascript - 简单的搜索api
- android - Android studio 3.6 无法打开模拟器
- git - Watson Data API - 创建项目失败
- windows - Arduino Pro Micro 作为 PC 上的“键盘” - 在 PC 上打印“=”而不是“-”HID 库