[英]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.