Tomito
Tomito

Reputation: 35

Run python script for one month non-stop

I have a code for scraping streaming tweets using Tweepy library for Python. I'd like to scrape streaming tweets for one month without stopping on Mac. Could you please advise me how to do it from a technical point of view?

Upvotes: 0

Views: 598

Answers (1)

Krish
Krish

Reputation: 1081

Just use the time module

import time
print(time.strftime("%b", time.localtime(time.time())))
>>> Jun

You can conditionally check the month like so:

print(time.strftime("%b", time.localtime(time.time())) == "Jun")
>>> true

Just execute your program in a while loop

while time.strftime("%b", time.localtime(time.time())) == "Jun":
     # your code here

Upvotes: 1

Related Questions