user5670731
user5670731

Reputation: 27

How to make ruby loops wait for 15 min after each 300 element?

I want to make ruby script that will print all followers for any account, but twitters API will gife me an error (too many requests) after 300 printed follower, how can i make loop to print the frist 300 then wait for 15 min then to start where its done to another 300?

Upvotes: 0

Views: 41

Answers (1)

Oleksandr Holubenko
Oleksandr Holubenko

Reputation: 4440

you can do it like:

some_variable = 0
loop do 
  #**your code that puts element ** 
  some_variable += 1
  sleep(15*60) if (some_variable % 300).zero?
end

Upvotes: 1

Related Questions