【发布时间】:2017-09-19 03:23:34
【问题描述】:
所以我试图在 Twitter API(tweepy 包装器)中搜索包含特定单词的推文。但是,在搜索单词时,我得到的结果很接近。 (即搜索“there”但 tweepy 返回“there's”。有没有办法用 tweepy 指定你想要的确切术语。
我的部分代码:
otherTweet = tweepy.Cursor(api.search, q=word and hashtag, count=1, lang="en").items(1) # searches for words needed to retweet later
for a in otherTweet:
ref = a.text.encode("unicode-escape")
if "#" in ref and word not in ref.split(" ") or not otherTweet:
otherTweet = tweepy.Cursor(api.search, q=word, count=1, lang="en").items(1) # Can't find tweet with right hashtag.
print "got here"
word 和 hashtag 都是变量,例如 word = "hello" hashtag = "#blessed"。我假设我对他们做了一些事情以获得特定条款。
【问题讨论】:
标签: python python-2.7 twitter tweepy