I'm an old man who's learning Python on his own
I want to check if many site url works well every 30 minutes and print it out. I succeeded in printing the response 200 code, but I got an error in the repetitive loop I'd appreciate your help.
import requests as rq
import time
url = “https://naver.com”
url1 = “https://google.com"
url2= “https://apple.com/"
result=rq.get(url)
result1=rq.get(url1)
result2=rq.get(url2)
print(result,result1,result2)
schedule.every(30).minutes.do(print)
Error Message
Request to add error content
import requests as rq
import schedule
import time
import threading
def run():
url = 'https://naver.com'
url1 = 'https://google.com'
url2 = 'https://apple.com/'
result=rq.get(url)
result1=rq.get(url1)
result2=rq.get(url2)
print(result, result1, result2)
# # schedule.every(60).seconds.do(run) #test verified
schedule.every(30).minutes.do(run)
def run2():
while 1:
schedule.run_pending()
time.sleep(60)
if __name__ == '__main__':
t1 = threading.Thread(target=run2)
t1.start()
I'm a beginner that I don't know well, but I'm leaving it to see if I can help you. Please try it like this.
© 2024 OneMinuteCode. All rights reserved.