如何遍历 tweepy Cursor? For 循环不起作用

问题描述

我试图用 tweepy 获取一些推文,但我一直收到错误 from selenium import webdriver import time import pyautogui web = webdriver.Chrome() print("trying to run the program") yeah = web.get("https://www.google.com") time.sleep(5) searchbar = web.find_element_by_xpath('/html/body/div[1]/div[3]/form/div[1]/div[1]/div[1]/div/div[2]/input') if pyautogui.click() == web.find_element_by_xpath('/html/body/div[1]/div[3]/form/div[1]/div[1]/div[1]/div/div[2]/input'): searchbar.send_keys("yeah! We did it!")

我的代码

'Cursor' object is not iterable

代码不起作用,它可以在 auth = tweepy.OAuthHandler(consumer_key,consumer_secret) auth.set_access_token(access_token,access_token_secret) api = tweepy.API(auth,wait_on_rate_limit=True,wait_on_rate_limit_notify=True) tweets = tweepy.Cursor(api.search,q="some-query",tweet_mode="extended",lang="it",result_type = "recent",count = 100) 对象外部调用 api.search,但显然不会对结果进行分页,并且始终检索相同的 100 条推文。

在这里错过了什么?我看到的所有示例都在 Cursor 循环中。

解决方法

在循环末尾添加 env->SetIntField(obj,fieldId,new_value) 起作用了。

tweets.next()