Search code examples
pythontwittertweepy

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?


Solution

  • 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