好的,所以我在这里有点麻烦。
这是我的代码:
profiles = [profiles here]
f_profiles = [formatted profiles go here, this is useless, im just doing this to make the printing stuff look more pretty]
DAILY_SCHEDULED_TIME = "6:00"
def routine():
print(colored(f"Getting from {f_profiles}"))
for profile in profiles:
print(colored(f"\nFetching from: {profile}\n"))
os.system(f"instaloader {profile} --no-video-thumbnails --no-captions --no-metadata-json --no-compress-json --no-profile-pic --dirname-pattern={os.getcwd()}\\media\\")
def attemptRoutine():
while(1):
try:
routine()
break
except OSError as err:
print("Routine Failed on " + "OS error: {0}".format(err))
time.sleep(60*60)
#attemptRoutine()
schedule.every().day.at("06:00").do(attemptRoutine)
attemptRoutine()
while True:
schedule.run_pending()
time.sleep(60) # wait one min
这样做只是下载模因,以便我的其他脚本可以将它们作为 SMS 发送到我的手机。
基本上我的问题是,这个脚本永远持续下去。当我真正需要每个用户大约 12 个时,它会从个人资料中下载 100 张照片和视频。
我在这里处于困境中,因为它是配置文件中永远配置文件的 for 循环,所以我需要一种方法来退出我对一个配置文件所做的事情,以便它可以在一定时间内移动到下一个配置文件。
例如
profile 1 -> Downloading memes.
(20 secs pass)
profile 1 -> quits -> profile 2 starts
etc and etc
但现在发生了什么:
profile 1 -> Downloading memes
(20 secs pass)
profile 1 -> Downloading Memes
(1 hour pass)
profile 1 -> Downloading memes
etc etc
这是因为正如我上面所说,配置文件中有 1000 张照片和视频中的 100 张。sooo,这有点问题。
我怎样才能做到这一点??
TL;DR 我想在 for 循环中创建一个计时器。这样它就可以停止它的工作并在一定时间后继续列表中的另一个对象(for循环)
n
本质上,我想在几秒钟后跳到我的 for 循环中的下一次迭代。
如果有人可以提供帮助,请这样做,任何和所有的帮助都将不胜感激,但如果你能说出我应该做什么,它是如何工作的或类似的事情,那也将不胜感激。
谢谢!