When i run this, it skips over i+1 days. What's going on here? I want i tweets from each of the last 30 days with this code.
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). The for loop will increment it for you already.
So just removing
x+=1
i+=1
should do the trick.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.