tweepy 中的深入 Twitter 搜索 API [英] In depth Twitter Search API in tweepy
问题描述
我想从给定的屏幕名称"中按关键字"搜索推文.
例如,来自BBCNews"的所有关于天气"的推文.
I wanted to search for tweets "by keyword" from a "given screen name."
Example, all tweets from "BBCNews" about "weather".
查看 Tweepy 库,我发现了以下代码:
Looking into Tweepy library, I found this code:
tweepy.Cursor(api.search,
q="weather",
rpp=100,
result_type="recent",
include_entities=True,
lang="en")
但是,我将如何过滤推文,使其仅来自英国广播公司的新闻?
However, how am I gonna filter the tweets such that they are only from BBCNews?
先谢谢你.
推荐答案
可用于过滤找到的推文的选项列表可在此处找到:https://dev.twitter.com/rest/public/search
The list of options you can use to filter the tweets you find can be found here : https://dev.twitter.com/rest/public/search
您可以将它们直接放入您的查询中,而无需关心 Tweepy.在你的情况下,我会建议
You can put them directly in your query, without caring about Tweepy. In your case, I would suggest
tweepy.Cursor(api.search,
q="weather from:BBCNews",
rpp=100,
result_type="recent",
include_entities=True,
lang="en")
您甚至可以在请求中添加 -filter:retweets
以消除转发.
You can even add -filter:retweets
to your request to get rid of the retweets.
这篇关于tweepy 中的深入 Twitter 搜索 API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!