[英]Trying to get 10 tweets a day for last 30 days using snscrape
When i run this, it skips over i+1 days.当我运行它时,它会跳过 i+1 天。 What's going on here?
这里发生了什么? I want i tweets from each of the last 30 days with this code.
我希望我在过去 30 天的每一天都使用此代码发布推文。
for x in range(30):
for i,tweet in enumerate(sntwitter.TwitterSearchScraper('ethereum exclude:retweets lang:en since:'+first_date+' until:'+second_date).get_items()):
if i>3:
break
if x < 30:
first_date = datetime.strptime(first_date, '%Y-%m-%d') + timedelta(days=1)
first_date = first_date.strftime('%Y-%m-%d')
second_date = datetime.strptime(second_date, '%Y-%m-%d') + timedelta(days=1)
second_date = second_date.strftime('%Y-%m-%d')
elif x==30:
final_day()
break
else:
break
run_the_tweets(tweet)
x+=1
i+=1
You don't need to manually increment either i
nor x
(which stands for the day index).您不需要手动增加
i
或x
(代表日索引)。 The for loop will increment it for you already. for 循环会为你增加它。
So just removing所以只是删除
x+=1
i+=1
should do the trick.应该做的伎俩。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.