[英]twython search string limit with twitter api : results missing
您好,我是编码的超级新手,仍处于阶段,复制粘贴,学习,更改一些变量,运行,交叉手指,拳头或举起拳头等。
我已经使用本教程创建了一个Twitter机器人
我的代码如下
import time
from twython import Twython, TwythonError
app_key = "xxxx"
app_secret = "xxxx"
oauth_token = "xxxx"
oauth_token_secret = "xxxx"
naughty_words = [" -RT"]
good_words = ["search phrase", "another search phrase", "yet another", "one more", "search phrase two", "TFW search phrase"]
filter = " OR ".join(good_words)
blacklist = " -".join(naughty_words)
keywords = filter + blacklist
twitter = Twython(app_key, app_secret, oauth_token, oauth_token_secret)
search_results = twitter.search(q=keywords, count=100)
try:
for tweet in search_results["statuses"]:
try:
twitter.retweet(id = tweet["id_str"])
except TwythonError as e:
print e
except TwythonError as e:
print e
time.sleep(300)
因此,当我运行代码时,有时会得到结果并将其重新发送,但是如果我仅使用两个搜索字词来运行代码,则会发现更多内容并将其重新发送。
我不知道我是否超过了Twitter搜索API的限制(我发现了几个不同的数字),或者OR的字符串OR OR OR混乱还是太长。
欢迎提供有关python和twitter api的任何建议。 非常感谢
编辑:UTF-8,URL编码的最大500个字符的搜索查询,包括运算符。 查询可能另外受到复杂性的限制。
即使使用OR和空格,我仍然没有超出限制。
我认为我通过使用%22而不是引号解决了问题。 非常感谢
good_words = [“%2this是一个短语%22”,“%22this是另一个%22”]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.