【问题标题】:Multiple query as a search word for q in tweepy.Cursor多个查询作为 tweepy.Cursor 中 q 的搜索词
【发布时间】:2020-08-25 21:58:11
【问题描述】:
tags = pd.read_csv("tags.csv", header=None)

words = []
for i in range(tags.shape[0]):
    words.append(str(tags[0][i]))

# Relevant #tags on Twitter
search_words = words

# Exclude retweets in our search
new_search = []
for i in range(len(search_words)):
    new_search.append(search_words[i] + " -filter:retweets")
for i in range(len(new_search)):
    # performs the search using the defined variables
    for tweet in limit_handled(tweepy.Cursor(api.search,
                           q=new_search[i],
                           count=count,
                           tweet_mode='extended',
                           lang=lang,
                           geocode=geocode,
                           result_type=result_type,
                           include_entities=include_entities,
                           since=date_since,
                           until=date_until).items(totalTweets)):

是否可以使用迭代器作为 q in 的参数来搜索多个标签/单词

tweepy.Cursor(q="一次一个字符串或多个")

【问题讨论】:

  • 这样做我得到“RuntimeError: generator raise StopIteration”
  • 我试过这个stackoverflow.com/a/25879571/4687973,但它运行了一些迭代,然后我又得到了 StopIteration 错误。

标签: python-3.x tweepy sentiment-analysis


【解决方案1】:

我认为这可能是由于速率限制限制,您是否尝试在创建 api 时将 wait_on_rate_limit 设置为 true

api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-12
    • 1970-01-01
    • 1970-01-01
    • 2015-11-02
    • 2012-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多