# -*- coding: utf-8 -*- """ Created on Wed May 02 16:43:10 2018 @author: TY """ # coding:utf8 #Introduce the time module import datetime import time #Define a crawler function to implement crawler function def pachong(): # Put the crawler in this class print 'The crawler has finished its work! ' # Define a function to judge the time def main(h, m): # Determine whether the local time matches the set time if h == 1 and m == 0: pachong() #break elif h == 17 and m == 5: pachong() #break else: # Check every 60 seconds print 'The owner is calm, the crawler is waiting for time. . . ' #Call the nowtime function every 60 seconds to make a new judgment time.sleep(60) nowtime() print 'Program finished! ' #Define a function to extract the current time def nowtime(): #Output the current time and assign it to hour and minute now = datetime.datetime.now() print(now.hour, now.minute) hour = now.hour minute = now.minute main(hour,minute) #Call the nowtime function to judge the time nowtime()
It is mainly judged by continuously calling the function to see if the requirements are met, and if the requirements are met, the data is captured